home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create the files:
- # Goban.c
- # node.c
- # sg.c
- # read.c
- # write.c
- # play.c
- # event.c
- # dialog.c
- # xgoban.c
- # action.c
- # misc.c
- # display.c
- # game.c
- # blackstone.bm
- # graystone.bm
- # stonemask.bm
- # whitestone.bm
- # icon.bm
- # Goban.h
- # GobanP.h
- # sg.h
- # xgoban.h
- # Goban.doc
- # xgoban.doc
- # xgoban.man
- # xgoban.6
- # xgoban.ad
- # README
- # CHANGE.Goban
- # Imakefile
- # xmailgo
- # mailgo.6
- # This archive created: Wed Jul 8 08:46:20 1992
- export PATH; PATH=/bin:$PATH
- if test -f 'Goban.c'
- then
- echo shar: will not over-write existing file "'Goban.c'"
- else
- cat << \SHAR_EOF > 'Goban.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include <X11/IntrinsicP.h>
- #include <X11/StringDefs.h>
- #include <X11/Xlib.h>
- #include <X11/cursorfont.h>
-
- #include "GobanP.h"
-
- #include "whitestone.bm"
- #include "blackstone.bm"
- #include "graystone.bm"
- #include "stonemask.bm"
-
- #define offset(field) XtOffset (GobanWidget, goban.field)
-
- static XtResource resources[] = {
- { XtNautoRedisplay , XtCAutoRedisplay , XtRBoolean , sizeof (Boolean) ,
- offset (auto_redisplay) , XtRImmediate , (caddr_t) TRUE },
- { XtNviewBottom , XtCPosition , XtRPosition , sizeof (Position) ,
- offset (bottom) , XtRImmediate , (caddr_t) 1 },
- { XtNcursor , XtCCursor , XtRInt , sizeof (int) ,
- offset (cursor) , XtRImmediate , (caddr_t) GbCGrayStone },
- { XtNfont , XtCFont , XtRFontStruct, sizeof (XFontStruct *),
- offset (font) , XtRString , "fixed" },
- { XtNforeground , XtCForeground , XtRPixel , sizeof (Pixel) ,
- offset (foreground) , XtRString , XtDefaultForeground },
- { XtNgameSize , XtCSize , XtRDimension , sizeof (Dimension) ,
- offset (game_size) , XtRImmediate, (caddr_t) 19 },
- { XtNviewLeft , XtCPosition , XtRPosition , sizeof (Position) ,
- offset (left) , XtRImmediate, (caddr_t) 1 },
- { XtNdisplayCoordinates, XtCDisplayCoordinates, XtRBoolean , sizeof (Boolean) ,
- offset (display_coordinates), XtRImmediate, (caddr_t) TRUE },
- { XtNpointSize , XtCSize , XtRDimension , sizeof (Dimension) ,
- offset (point_size) , XtRImmediate , (caddr_t) 26 },
- { XtNviewRight , XtCPosition , XtRPosition , sizeof (Position) ,
- offset (right) , XtRImmediate , (caddr_t) 19 },
- { XtNviewTop , XtCPosition , XtRPosition , sizeof (Position) ,
- offset (top) , XtRImmediate , (caddr_t) 19 },
- { XtNwhiteStoneForeground, XtCForeground , XtRPixel , sizeof (Pixel) ,
- offset (white_fg) , XtRString , "black" },
- { XtNwhiteStoneBackground, XtCBackground , XtRPixel , sizeof (Pixel) ,
- offset (white_bg) , XtRString , "white" },
- { XtNwhiteStoneBorder , XtCBorderColor , XtRPixel , sizeof (Pixel) ,
- offset (white_bd) , XtRString , "black" },
- { XtNblackStoneForeground, XtCForeground , XtRPixel , sizeof (Pixel) ,
- offset (black_fg) , XtRString , "white" },
- { XtNblackStoneBackground, XtCBackground , XtRPixel , sizeof (Pixel) ,
- offset (black_bg) , XtRString , "black" },
- { XtNblackStoneBorder , XtCBorderColor , XtRPixel , sizeof (Pixel) ,
- offset (black_bd) , XtRString , "black" },
- };
-
- static void ClassInitialize ();
- static void Initialize ();
- static void Redisplay ();
- static void Realize ();
- static void Destroy ();
- static void Resize ();
- static void DrawPoint ();
- static Boolean SetValues ();
-
- GobanClassRec gobanClassRec = {
- { /* core fields */
- /* superclass */ (WidgetClass) &widgetClassRec,
- /* class_name */ "Goban",
- /* widget_size */ sizeof (GobanRec),
- /* class_initialize */ ClassInitialize,
- /* class_part_initialize */ NULL,
- /* class_inited */ FALSE,
- /* initialize */ Initialize,
- /* initialize_hook */ NULL,
- /* realize */ Realize,
- /* actions */ NULL,
- /* num_actions */ 0,
- /* resources */ resources,
- /* num_resources */ XtNumber (resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure */ TRUE,
- /* compress_enterleave */ TRUE,
- /* visible_interest */ FALSE,
- /* destroy */ Destroy,
- /* resize */ Resize,
- /* expose */ Redisplay,
- /* set_values */ SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_private */ NULL,
- /* tm_table */ NULL,
- /* query_geometry */ XtInheritQueryGeometry,
- /* display_accelerator */ XtInheritDisplayAccelerator,
- /* extension */ NULL
- }
- };
-
- WidgetClass gobanWidgetClass = (WidgetClass) &gobanClassRec;
-
- /****************************************************************************************************************
- */
-
- void GbRedisplayBoard (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Dimension width = w->core.width;
- Dimension height = w->core.height;
-
- if (XtIsRealized (w))
- XCopyArea (XtDisplay (w), gw->goban.picture, XtWindow (w), gw->goban.copy_gc, 0, 0, width, height, 0, 0);
- }
-
- /****************************************************************************************************************
- */
-
- void GbClearBoard (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Boolean redisplay = gw->goban.auto_redisplay;
- Position x;
- Position y;
-
- gw->goban.auto_redisplay = FALSE;
-
- for (x = 1; x <= gw->goban.game_size; x++)
- for (y = 1; y <= gw->goban.game_size; y++)
- GbSetPoint (w, x, y, GbEmptyPoint);
-
- gw->goban.auto_redisplay = redisplay;
-
- if (redisplay == TRUE)
- GbRedisplayBoard (w);
- }
-
- /****************************************************************************************************************
- */
-
- void GbClearMarks (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Boolean redisplay = gw->goban.auto_redisplay;
- Position x;
- Position y;
-
- gw->goban.auto_redisplay = FALSE;
-
- for (x = 1; x <= gw->goban.game_size; x++)
- for (y = 1; y <= gw->goban.game_size; y++) {
-
- gw->goban.points[x][y].mark1 = 0;
- gw->goban.points[x][y].mark2 = 0;
- gw->goban.points[x][y].num = 0;
-
- if (x >= gw->goban.left && y >= gw->goban.bottom && x <= gw->goban.right && y <= gw->goban.top)
- if (gw->goban.points[x][y].free == 1)
- DrawPoint (w, x, y, GbEmptyPoint);
- else
- if (gw->goban.points[x][y].black == 1)
- DrawPoint (w, x, y, GbBlackStone);
- else
- DrawPoint (w, x, y, GbWhiteStone);
- }
-
- gw->goban.auto_redisplay = redisplay;
-
- if (redisplay == TRUE)
- GbRedisplayBoard (w);
- }
-
- /****************************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void GbSetPoint (w, x, y, color)
- Widget w;
- Position x;
- Position y;
- GbPointState color;
- {
- GobanWidget gw = (GobanWidget) w;
-
- if (x >= 1 && y >= 1 && x <= gw->goban.game_size && y <= gw->goban.game_size) {
- switch (color) {
-
- case GbBlackStone :
- gw->goban.points[x][y].free = 0;
- gw->goban.points[x][y].black = 1;
- break;
-
- case GbWhiteStone :
- gw->goban.points[x][y].free = 0;
- gw->goban.points[x][y].black = 0;
- break;
-
- case GbEmptyPoint :
- gw->goban.points[x][y].free = 1;
- break;
- }
-
- gw->goban.points[x][y].num = 0;
- gw->goban.points[x][y].mark1 = 0;
- gw->goban.points[x][y].mark2 = 0;
-
- if (x >= gw->goban.left && y >= gw->goban.bottom && x <= gw->goban.right && y <= gw->goban.top)
- DrawPoint (w, x, y, color);
- }
- }
-
- /****************************************************************************************************************
- */
-
- /* ARGSUSED */
-
- Boolean GbGetPositionFromStone (w, x, y)
- GobanWidget w;
- Position *x;
- Position *y;
- {
- if (*x >= w->goban.left && *y >= w->goban.bottom && *x <= w->goban.right && *y <= w->goban.top) {
-
- *x = ((w->goban.x_offset + w->goban.point_size * *x) * 2 + w->goban.point_size) / 2;
- *y = ((w->goban.y_offset - w->goban.point_size * *y) * 2 + w->goban.point_size) / 2;
-
- return TRUE;
- }
-
- else
- return FALSE;
- }
-
- /****************************************************************************************************************
- */
-
- /* ARGSUSED */
-
- Boolean GbGetStoneFromPosition (w, x, y)
- Widget w;
- Position *x;
- Position *y;
- {
- GobanWidget gw = (GobanWidget) w;
- Dimension point_size = gw->goban.point_size;
- Position xmin = gw->goban.x_offset + point_size * gw->goban.left + 1;
- Position ymin = gw->goban.y_offset - point_size * gw->goban.top + 1;
- Position xmax = gw->goban.x_offset + point_size * (gw->goban.right + 1) - 1;
- Position ymax = gw->goban.y_offset - point_size * (gw->goban.bottom - 1) - 1;
-
- if (*x > xmin && *x < xmax && *y > ymin && *y < ymax) {
-
- *x = (*x - gw->goban.x_offset - 1) / point_size;
- *y = (gw->goban.y_offset - *y + point_size + 1) / point_size;
-
- return TRUE;
- }
-
- return FALSE;
- }
-
- /****************************************************************************************************************
- */
-
- void GbSetNum (w, x, y, num)
- Widget w;
- Position x;
- Position y;
- int num;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- GC draw_gc;
- GC undraw_gc;
- XCharStruct extent;
- XExposeEvent event;
- int ascent;
- int descent;
- int direction;
- int X;
- int Y;
- char s[3];
- int len = 0;
-
- if (num >= 0 && num <= 999 && x >= 1 && y >= 1 && x <= gw->goban.game_size && y <= gw->goban.game_size) {
-
- gw->goban.points[x][y].num = num;
- gw->goban.points[x][y].mark1 = 0;
- gw->goban.points[x][y].mark2 = 0;
-
- if (x >= gw->goban.left && y >= gw->goban.bottom && x <= gw->goban.right && y <= gw->goban.top) {
-
- if (gw->goban.points[x][y].free == 0) {
-
- if (num == 0) {
- if (gw->goban.points[x][y].black == 1)
- DrawPoint (w, x, y, GbBlackStone);
- else
- DrawPoint (w, x, y, GbWhiteStone);
- }
-
- else {
- if (gw->goban.points[x][y].black == 1) {
- draw_gc = gw->goban.black_fg_gc;
- undraw_gc = gw->goban.black_bg_gc;
- } else {
- draw_gc = gw->goban.white_fg_gc;
- undraw_gc = gw->goban.white_bg_gc;
- }
-
- X = (gw->goban.x_offset + gw->goban.point_size * x) * 2 + gw->goban.point_size;
- Y = (gw->goban.y_offset - gw->goban.point_size * y) * 2 + gw->goban.point_size;
-
- if (num > 99)
- s[len++] = '0' + (num % 1000) / 100;
- if (num > 9)
- s[len++] = '0' + (num % 100) / 10;
- s[len++] = '0' + num % 10;
-
- XQueryTextExtents (display, XGContextFromGC (draw_gc),
- s, len, &direction, &ascent, &descent, &extent);
-
- if (extent.width + extent.descent + extent.ascent < gw->goban.point_size - 1) {
- XFillArc (display, gw->goban.picture, undraw_gc,
- (int) (X - gw->goban.point_size) / 2 + 2, (int) (Y - gw->goban.point_size) / 2 + 2,
- (unsigned int) gw->goban.point_size - 4, (unsigned int) gw->goban.point_size - 4,
- 0, 360 * 64);
- XDrawString (display, gw->goban.picture, draw_gc,
- (X - extent.width) / 2 - extent.lbearing + 1,
- (Y + extent.ascent - extent.descent) / 2 + 1, s, len);
- }
-
- if (gw->goban.auto_redisplay == TRUE && XtIsRealized (w) == TRUE) {
- event.x = (X - gw->goban.point_size) / 2;
- event.y = (Y - gw->goban.point_size) / 2;
- event.width = gw->goban.point_size;
- event.height = gw->goban.point_size;
-
- Redisplay (w, &event, (Region) NULL);
- }
- }
- }
- }
- }
- }
-
- /****************************************************************************************************************
- */
-
- void GbSetMark (w, x, y, c1, c2)
- Widget w;
- Position x;
- Position y;
- unsigned char c1;
- unsigned char c2;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- int len = 0;
- XCharStruct extent;
- XExposeEvent event;
- int ascent;
- int descent;
- int direction;
- int X;
- int Y;
- int radius;
- char s[2];
- XSegment segment[4];
- GC mark_gc;
- GC erase_gc;
-
- if (x >= 1 && y >= 1 && x <= gw->goban.game_size && y <= gw->goban.game_size) {
-
- if (c1 != 0 || c2 != 0)
- GbSetMark (w, x, y, 0, 0);
-
- gw->goban.points[x][y].mark1 = c1;
- gw->goban.points[x][y].mark2 = c2;
- gw->goban.points[x][y].num = 0;
-
- if (x >= gw->goban.left && y >= gw->goban.bottom && x <= gw->goban.right && y <= gw->goban.top) {
-
- if (c1 == 0 && c2 == 0) {
- if (gw->goban.points[x][y].free == 0)
- if (gw->goban.points[x][y].black == 1)
- DrawPoint (w, x, y, GbBlackStone);
- else
- DrawPoint (w, x, y, GbWhiteStone);
- else
- DrawPoint (w, x, y, GbEmptyPoint);
- }
-
- else {
- X = (gw->goban.x_offset + gw->goban.point_size * x) * 2 + gw->goban.point_size;
- Y = (gw->goban.y_offset - gw->goban.point_size * y) * 2 + gw->goban.point_size;
-
- if (gw->goban.points[x][y].free == 0)
- if (gw->goban.points[x][y].black == 1) {
- mark_gc = gw->goban.black_fg_gc;
- erase_gc = gw->goban.black_bg_gc;
- }
- else {
- mark_gc = gw->goban.white_fg_gc;
- erase_gc = gw->goban.white_bg_gc;
- }
-
- else {
- mark_gc = gw->goban.foreground_gc;
- erase_gc = gw->goban.background_gc;
- }
-
- if (c1 == 0) {
- radius = 10 * gw->goban.point_size / 15;
-
- if (gw->goban.points[x][y].free == 0)
- XFillArc (display, gw->goban.picture, erase_gc,
- (int) (X - gw->goban.point_size) / 2 + 2, (int) (Y - gw->goban.point_size) / 2 + 2,
- (unsigned int) gw->goban.point_size - 4, (unsigned int) gw->goban.point_size - 4,
- 0, 360 * 64);
- else
- XFillArc (display, gw->goban.picture, erase_gc,
- (int) (X - radius) / 2, (int) (Y - radius) / 2,
- (unsigned int) radius, (unsigned int) radius,
- 0, 360 * 64);
-
- switch (c2) {
-
- case GbMTriangleMark :
- radius -= 4;
-
- segment[0].x1 = (short) X / 2;
- segment[0].x2 = (short) (X / 2 + (86 * radius + 100) / 200);
- segment[0].y1 = (short) (Y / 2 - (radius - 1) / 2);
- segment[0].y2 = (short) (Y / 2 + (radius + 4) / 4);
-
- segment[1].x1 = (short) segment[0].x2;
- segment[1].x2 = (short) (X / 2 - (86 * radius + 100) / 200);
- segment[1].y1 = (short) segment[0].y2;
- segment[1].y2 = (short) (Y / 2 + (radius + 4) / 4);
-
- segment[2].x1 = (short) segment[1].x2;
- segment[2].x2 = (short) segment[0].x1;
- segment[2].y1 = (short) segment[1].y2;
- segment[2].y2 = (short) segment[0].y1;
-
- XDrawSegments (display, gw->goban.picture, mark_gc, segment, 3);
- break;
-
- case GbMSquareMark :
- radius = 10 * radius / 14 - 2;
-
- XDrawRectangle (display, gw->goban.picture, mark_gc,
- (X - radius) / 2, (Y - radius) / 2,
- (unsigned int) radius, (unsigned int) radius);
- break;
-
- case GbMDCrossMark :
- radius = 10 * radius / 14 - 2;
-
- segment[0].x1 = (short) (X - radius) / 2;
- segment[0].x2 = (short) segment[0].x1 + radius;
- segment[0].y1 = (short) (Y - radius) / 2;
- segment[0].y2 = (short) segment[0].y1 + radius;
-
- segment[1].x1 = (short) (X - radius) / 2 + radius;
- segment[1].x2 = (short) segment[1].x1 - radius;
- segment[1].y1 = (short) (Y - radius) / 2;
- segment[1].y2 = (short) segment[1].y1 + radius;
-
- XDrawSegments (display, gw->goban.picture, mark_gc, segment, 2);
- break;
-
- case GbMVCrossMark :
- radius -= 4;
-
- segment[0].x1 = (short) X / 2;
- segment[0].x2 = (short) segment[0].x1;
- segment[0].y1 = (short) (Y - radius) / 2;
- segment[0].y2 = (short) segment[0].y1 + radius;
-
- segment[1].x1 = (short) (X - radius) / 2;
- segment[1].x2 = (short) segment[1].x1 + radius;
- segment[1].y1 = (short) Y / 2;
- segment[1].y2 = (short) segment[1].y1;
-
- XDrawSegments (display, gw->goban.picture, mark_gc, segment, 2);
- break;
-
- case GbMDiamondMark :
- radius -= 4;
-
- segment[0].x1 = (short) X / 2;
- segment[0].x2 = (short) segment[0].x1 + radius / 2;
- segment[0].y1 = (short) (Y - radius) / 2;
- segment[0].y2 = (short) segment[0].y1 + radius / 2;
-
- segment[1].x1 = (short) segment[0].x2;
- segment[1].x2 = (short) segment[0].x1;
- segment[1].y1 = (short) segment[0].y2;
- segment[1].y2 = (short) segment[1].y1 + radius / 2;
-
- segment[2].x1 = (short) segment[1].x2;
- segment[2].x2 = (short) segment[2].x1 - radius / 2;
- segment[2].y1 = (short) segment[1].y2;
- segment[2].y2 = (short) segment[1].y1;
-
- segment[3].x1 = (short) segment[2].x2;
- segment[3].x2 = (short) segment[0].x1;
- segment[3].y1 = (short) segment[2].y2;
- segment[3].y2 = (short) segment[0].y1;
-
- XDrawSegments (display, gw->goban.picture, mark_gc, segment, 4);
- break;
- }
- }
-
- else {
- s[len++] = c1;
- if (c2 != 0)
- s[len++] = c2;
-
- XQueryTextExtents (display, XGContextFromGC (mark_gc), s, len, &direction, &ascent, &descent, &extent);
-
- radius = extent.width + extent.descent + extent.ascent;
-
- if (radius < gw->goban.point_size - 1) {
- if (gw->goban.points[x][y].free == 0)
- XFillArc (display, gw->goban.picture, erase_gc,
- (int) (X - gw->goban.point_size) / 2 + 2, (int) (Y - gw->goban.point_size) / 2 + 2,
- (unsigned int) gw->goban.point_size - 4, (unsigned int) gw->goban.point_size - 4,
- 0, 360 * 64);
- else
- XFillArc (display, gw->goban.picture, erase_gc,
- (int) (X - radius) / 2, (int) (Y - radius) / 2,
- (unsigned int) radius, (unsigned int) radius,
- 0, 360 * 64);
-
- XDrawString (display, gw->goban.picture, mark_gc,
- (X - extent.width) / 2 - extent.lbearing + 1,
- (Y + extent.ascent - extent.descent) / 2 + 1, s, len);
- }
- }
-
- if (gw->goban.auto_redisplay == TRUE && XtIsRealized (w) == TRUE) {
- event.x = (X - gw->goban.point_size) / 2;
- event.y = (Y - gw->goban.point_size) / 2;
- event.width = gw->goban.point_size;
- event.height = gw->goban.point_size;
-
- Redisplay (w, &event, (Region) NULL);
- }
- }
- }
- }
- }
-
- /****************************************************************************************************************
- */
-
- /* ARGSUSED */
-
- static void Redisplay (w, event, region)
- Widget w;
- XExposeEvent *event;
- Region region;
- {
- GobanWidget gw = (GobanWidget) w;
- Position x = event->x;
- Position y = event->y;
- Dimension width = event->width;
- Dimension height = event->height;
-
- XCopyArea (XtDisplay (w), gw->goban.picture, XtWindow (w), gw->goban.copy_gc, x, y, width, height, x, y);
- }
-
- /****************************************************************************************************************
- */
-
- /* ARGSUSED */
-
- static void CvtStringToCursor (args, num_args, fromVal, toVal)
- XrmValuePtr args; /* unused */
- Cardinal *num_args; /* unused */
- XrmValuePtr fromVal;
- XrmValuePtr toVal;
- {
- static int cursor;
- static XrmQuark QWhiteStone;
- static XrmQuark QBlackStone;
- static XrmQuark QGrayStone;
- XrmQuark quark;
- char lowerName[256];
- static Boolean inited = FALSE;
-
- if (inited == FALSE) {
- QWhiteStone = XrmStringToQuark (XtEgbWhiteStone);
- QBlackStone = XrmStringToQuark (XtEgbBlackStone);
- QGrayStone = XrmStringToQuark (XtEgbGrayStone);
- inited = TRUE;
- }
-
- XmuCopyISOLatin1Lowered (lowerName, (String) fromVal->addr);
- quark = XrmStringToQuark (lowerName);
-
- if (quark == QWhiteStone)
- cursor = GbCWhiteStone;
- else if (quark == QBlackStone)
- cursor = GbCBlackStone;
- else if (quark == QGrayStone)
- cursor = GbCGrayStone;
- else {
- toVal->size = 0;
- toVal->addr = NULL;
- return;
- }
-
- toVal->size = sizeof (cursor);
- toVal->addr = (caddr_t) &cursor;
- }
-
- /****************************************************************************************************************
- */
-
- static void ClassInitialize()
- {
- XtAddConverter (XtRString, XtRInt, (XtConverter) CvtStringToCursor, NULL, 0);
- }
-
- /****************************************************************************************************************
- */
-
- static void InitializePixmap (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- Drawable window = RootWindowOfScreen (XtScreen (w));
- Dimension width = w->core.width;
- Dimension height = w->core.height;
-
- gw->goban.board = XCreatePixmap (display, window, width, height, (unsigned int) DefaultDepthOfScreen (XtScreen (w)));
- gw->goban.picture = XCreatePixmap (display, window, width, height, (unsigned int) DefaultDepthOfScreen (XtScreen (w)));
- }
-
- /****************************************************************************************************************
- */
-
- static void InitializeGC (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- XtGCMask mask = GCForeground | GCBackground | GCFont;
- XGCValues values;
-
- values.font = gw->goban.font->fid;
- values.background = w->core.background_pixel;
-
- values.foreground = gw->goban.white_fg;
- gw->goban.white_fg_gc = XCreateGC (display, gw->goban.picture, mask, &values);
- values.foreground = gw->goban.white_bg;
- gw->goban.white_bg_gc = XCreateGC (display, gw->goban.picture, mask, &values);
- values.foreground = gw->goban.white_bd;
- gw->goban.white_bd_gc = XCreateGC (display, gw->goban.picture, mask, &values);
-
- values.foreground = gw->goban.black_fg;
- gw->goban.black_fg_gc = XCreateGC (display, gw->goban.picture, mask, &values);
- values.foreground = gw->goban.black_bg;
- gw->goban.black_bg_gc = XCreateGC (display, gw->goban.picture, mask, &values);
- values.foreground = gw->goban.black_bd;
- gw->goban.black_bd_gc = XCreateGC (display, gw->goban.picture, mask, &values);
-
- values.foreground = gw->goban.foreground;
- gw->goban.foreground_gc = XCreateGC (display, gw->goban.picture, mask, &values);
-
- if (gw->core.background_pixmap != XtUnspecifiedPixmap) {
- values.tile = gw->core.background_pixmap;
- values.fill_style = FillTiled;
- mask |= GCTile | GCFillStyle;
- }
-
- values.foreground = w->core.background_pixel;
- values.background = gw->goban.foreground;
- gw->goban.background_gc = XCreateGC (display, gw->goban.picture, mask, &values);
-
- gw->goban.copy_gc = XCreateGC (display, gw->goban.picture, (XtGCMask) 0, (XGCValues *) NULL);
- }
-
- /****************************************************************************************************************
- */
- static void InitializeCursor (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- Drawable window = RootWindowOfScreen (XtScreen (w));
- Pixel black = BlackPixel (display, DefaultScreen (display));
- Pixel white = WhitePixel (display, DefaultScreen (display));
-
- static XColor black_color = { 0, 0, 0, 0 }; /* black */
- static XColor white_color = { 0, 65535, 65535, 65535 }; /* white */
-
- /* Some teminals invert the mask with BlackPixel and WhitePixel */
- /* should use black and white instead of 1 and 0 but depth is 1 ... */
- /* will probably have trouble with some special colormaps */
-
- gw->goban.white_stone = XCreatePixmapFromBitmapData
- (display, window, whitestone_bits, whitestone_width, whitestone_height, 1, 0, 1);
- gw->goban.black_stone = XCreatePixmapFromBitmapData
- (display, window, blackstone_bits, blackstone_width, blackstone_height, 1, 0, 1);
- gw->goban.gray_stone = XCreatePixmapFromBitmapData
- (display, window, graystone_bits , graystone_width , graystone_height , 1, 0, 1);
- gw->goban.mouse_mask = XCreatePixmapFromBitmapData
- (display, window, stonemask_bits , stonemask_width , stonemask_height , 1, 0, 1);
-
- gw->goban.white_cursor =
- XCreatePixmapCursor (display, gw->goban.white_stone, gw->goban.mouse_mask,
- &black_color, &white_color, whitestone_x_hot, whitestone_y_hot);
- gw->goban.black_cursor =
- XCreatePixmapCursor (display, gw->goban.black_stone, gw->goban.mouse_mask,
- &black_color, &white_color, blackstone_x_hot, blackstone_y_hot);
- gw->goban.gray_cursor =
- XCreatePixmapCursor (display, gw->goban.gray_stone, gw->goban.mouse_mask,
- &black_color, &white_color, graystone_x_hot , graystone_y_hot );
-
- gw->goban.font_cursor = XCreateFontCursor (display, XC_question_arrow);
- }
-
- /****************************************************************************************************************
- */
-
- static void DestroyPixmap (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
-
- XFreePixmap (display, gw->goban.picture);
- XFreePixmap (display, gw->goban.board );
- }
-
- /****************************************************************************************************************
- */
-
- static void DestroyGC (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
-
- XFreeGC (display, gw->goban.black_fg_gc );
- XFreeGC (display, gw->goban.black_bg_gc );
- XFreeGC (display, gw->goban.black_bd_gc );
- XFreeGC (display, gw->goban.white_fg_gc );
- XFreeGC (display, gw->goban.white_bg_gc );
- XFreeGC (display, gw->goban.white_bd_gc );
- XFreeGC (display, gw->goban.foreground_gc);
- XFreeGC (display, gw->goban.background_gc);
- XFreeGC (display, gw->goban.copy_gc );
- }
-
- /****************************************************************************************************************
- */
-
- static void Destroy (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
-
- DestroyPixmap (w);
- DestroyGC (w);
-
- XFreePixmap (display, gw->goban.white_stone );
- XFreePixmap (display, gw->goban.black_stone );
- XFreePixmap (display, gw->goban.gray_stone );
- XFreePixmap (display, gw->goban.mouse_mask );
-
- XFreeCursor (display, gw->goban.white_cursor );
- XFreeCursor (display, gw->goban.black_cursor );
- XFreeCursor (display, gw->goban.gray_cursor );
- XFreeCursor (display, gw->goban.font_cursor );
- }
-
- /****************************************************************************************************************
- */
-
- static void Realize (w, valuemaskp, attr)
- Widget w;
- XtValueMask *valuemaskp;
- XSetWindowAttributes *attr;
- {
- GobanWidget gw = (GobanWidget) w;
-
- *valuemaskp |= CWCursor;
-
- switch (gw->goban.cursor) {
- case GbCGrayStone : attr->cursor = gw->goban.gray_cursor ; break;
- case GbCBlackStone : attr->cursor = gw->goban.black_cursor; break;
- case GbCWhiteStone : attr->cursor = gw->goban.white_cursor; break;
- default : attr->cursor = gw->goban.font_cursor ; break;
- }
-
- XtCreateWindow (w, InputOutput, (Visual *) CopyFromParent, *valuemaskp, attr);
- }
-
- /****************************************************************************************************************
- */
-
- static char *stars[18] = {
- "", /* 2 */
- "", /* 3 */
- "", /* 4 */
- "", /* 5 */
- "", /* 6 */
- "", /* 7 */
- "cccffcff", /* 8 */
- "cccgeegcgg", /* 9 */
- "ccchhchh", /* 10 */
- "cccfcifcfffiicifii", /* 11 */
- "dddiidii", /* 12 */
- "dddjggjdjj", /* 13 */
- "dddkkdkk", /* 14 */
- "dddhdlhdhhhlldlhll", /* 15 */
- "dddmmdmm", /* 16 */
- "dddidnidiiinndninn", /* 17 */
- "dddoodoo", /* 18 */
- "dddjdpjdjjjppdpjpp", /* 19 */
- };
-
- static void DrawBoard (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- XSegment segment[44];
- int segc;
- Position game_size = (Position) gw->goban.game_size;
- Position point_size = (Position) gw->goban.point_size;
- Position star_size = 4;
- Position xbase = gw->goban.x_offset + point_size / 2;
- Position ybase = gw->goban.y_offset - point_size / 2;
- Position xmin = gw->goban.x_offset + point_size * gw->goban.left + 1;
- Position ymin = gw->goban.y_offset - point_size * gw->goban.top + 1;
- Position xmax = gw->goban.x_offset + point_size * (gw->goban.right + 1) - 1;
- Position ymax = gw->goban.y_offset - point_size * (gw->goban.bottom - 1) - 1;
- char *star;
- int x;
- int y;
-
- XFillRectangle (display, gw->goban.board, gw->goban.background_gc, 0, 0, w->core.width, w->core.height);
-
- if (point_size > 0) {
- segc = 0;
- for (y = gw->goban.bottom - 1; y < gw->goban.top; y++, segc++) {
- segment[segc].x1 = (short) Max ((int) xbase + point_size , xmin);
- segment[segc].x2 = (short) Min ((int) xbase + point_size * game_size, xmax);
- segment[segc].y1 = (short) (ybase - point_size * y);
- segment[segc].y2 = (short) (ybase - point_size * y);
- }
-
- for (x = gw->goban.left; x <= gw->goban.right; x++, segc++) {
- segment[segc].x1 = (short) (xbase + point_size * x);
- segment[segc].x2 = (short) (xbase + point_size * x);
- segment[segc].y1 = (short) Max (ybase - point_size * (game_size - 1), ymin);
- segment[segc].y2 = (short) Min (ybase, ymax);
- }
-
- if (gw->goban.top == gw->goban.game_size) {
- segment[segc].x1 = (short) Max (xbase + point_size - 1, xmin);
- segment[segc].x2 = (short) Min (xbase + point_size * game_size + 1, xmax);
- segment[segc].y1 = (short) (ybase - point_size * (game_size - 1) - 1);
- segment[segc].y2 = (short) (ybase - point_size * (game_size - 1) - 1);
- segc++;
- }
-
- if (gw->goban.bottom == 1) {
- segment[segc].x1 = (short) Max (xbase + point_size - 1, xmin);
- segment[segc].x2 = (short) Min (xbase + point_size * game_size + 1, xmax);
- segment[segc].y1 = (short) (ybase + 1);
- segment[segc].y2 = (short) (ybase + 1);
- segc++;
- }
-
- if (gw->goban.left == 1) {
- segment[segc].x1 = (short) (xbase + point_size - 1);
- segment[segc].x2 = (short) (xbase + point_size - 1);
- segment[segc].y1 = (short) Max (ybase - point_size * (game_size - 1) - 1, ymin);
- segment[segc].y2 = (short) Min (ybase + 1, ymax);
- segc++;
- }
-
- if (gw->goban.right == gw->goban.game_size) {
- segment[segc].x1 = (short) (xbase + point_size * game_size + 1);
- segment[segc].x2 = (short) (xbase + point_size * game_size + 1);
- segment[segc].y1 = (short) Max (ybase - point_size * (game_size - 1) - 1, ymin);
- segment[segc].y2 = (short) Min (ybase + 1, ymax);
- segc++;
- }
-
- XDrawSegments (display, gw->goban.board, gw->goban.foreground_gc, segment, segc);
-
- if (point_size > 8) {
- star_size = (point_size > 10) ? 4 : 2;
- star = stars[game_size - 2];
-
- while (*star != '\0') {
- x = *star++ - 'a' + 1;
- y = *star++ - 'a' + 1;
-
- if (x >= gw->goban.left && x <= gw->goban.right && y >= gw->goban.bottom && y <= gw->goban.top) {
- x = gw->goban.x_offset + (point_size * (2 * x + 1)) / 2;
- y = gw->goban.y_offset - (point_size * (2 * y - 1)) / 2;
-
- XDrawArc (display, gw->goban.board, gw->goban.foreground_gc,
- (int) x - star_size / 2, (int) y - star_size / 2,
- (unsigned int) star_size, (unsigned int) star_size,
- 0, 64 * 360);
- XFillArc (display, gw->goban.board, gw->goban.foreground_gc,
- (int) x - star_size / 2, (int) y - star_size / 2,
- (unsigned int) star_size, (unsigned int) star_size,
- 0, 64 * 360);
- }
- }
- }
- }
-
- XCopyArea (display, gw->goban.board, gw->goban.picture, gw->goban.copy_gc, 0, 0,
- w->core.width, w->core.height, 0, 0);
- }
-
- /****************************************************************************************************************
- */
-
- static void DrawCoordinates (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- XCharStruct extent;
- int point_size = gw->goban.point_size;
- char s[2];
- int len;
- int ascent;
- int descent;
- int direction;
- int xbase;
- int ybase;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
-
- s[0] = s[1] = '8';
- XQueryTextExtents (display, XGContextFromGC (gw->goban.foreground_gc),
- s, 2, &direction, &ascent, &descent, &extent);
-
- if ((point_size > extent.width + 2) && (point_size > extent.ascent + extent.descent + 2)) {
- xbase = 2 * gw->goban.x_offset + point_size;
- ybase = 2 * gw->goban.y_offset - point_size;
-
- if (gw->goban.display_coordinates == TRUE) {
-
- for (x = gw->goban.left; x <= gw->goban.right; x++) {
- s[0] = 'A' - 1 + ((x > 8) ? (x + 1) : x);
- XQueryTextExtents (display, XGContextFromGC (gw->goban.foreground_gc),
- s, 1, &direction, &ascent, &descent, &extent);
-
- XDrawString (display, gw->goban.board, gw->goban.foreground_gc,
- (xbase - extent.width) / 2 + point_size * x - extent.lbearing + 1,
- (ybase + extent.ascent - extent.descent) / 2 - point_size * gw->goban.top + 1, s, 1);
- XDrawString (display, gw->goban.board, gw->goban.foreground_gc,
- (xbase - extent.width) / 2 + point_size * x - extent.lbearing + 1,
- (ybase + extent.ascent - extent.descent) / 2 - point_size * (gw->goban.bottom - 2) + 1, s, 1);
- }
- }
-
- x = gw->goban.x_offset + point_size * gw->goban.left;
- y = gw->goban.y_offset - point_size * (gw->goban.top + 1);
- width = point_size * (gw->goban.right - gw->goban.left + 1);
- height = point_size;
-
- if (gw->goban.display_coordinates == FALSE)
- XFillRectangle (display, gw->goban.board, gw->goban.background_gc, x, y, width, height);
- XCopyArea (display, gw->goban.board, gw->goban.picture, gw->goban.copy_gc, x, y, width, height, x, y);
-
- y = gw->goban.y_offset - point_size * (gw->goban.bottom - 1);
-
- if (gw->goban.display_coordinates == FALSE)
- XFillRectangle (display, gw->goban.board, gw->goban.background_gc, x, y, width, height);
- XCopyArea (display, gw->goban.board, gw->goban.picture, gw->goban.copy_gc, x, y, width, height, x, y);
-
- ybase += 2 * point_size;
-
- for (y = gw->goban.bottom; y <= gw->goban.top; y++) {
- if (gw->goban.display_coordinates == TRUE) {
- len = 0;
- if (y > 9)
- s[len++] = '1';
- s[len++] = '0' + y % 10;
- XQueryTextExtents (display, XGContextFromGC (gw->goban.foreground_gc),
- s, len, &direction, &ascent, &descent, &extent);
-
- XDrawString (display, gw->goban.board, gw->goban.foreground_gc,
- (xbase - extent.width) / 2 + point_size * (gw->goban.left - 1) - extent.lbearing + 1,
- (ybase + extent.ascent - extent.descent) / 2 - point_size * y + 1, s, len);
- XDrawString (display, gw->goban.board, gw->goban.foreground_gc,
- (xbase - extent.width) / 2 + point_size * (gw->goban.right + 1) - extent.lbearing + 1,
- (ybase + extent.ascent - extent.descent) / 2 - point_size * y + 1, s, len);
- }
- }
-
- x = gw->goban.x_offset + point_size * (gw->goban.left - 1);
- y = gw->goban.y_offset - point_size * gw->goban.top;
- width = point_size;
- height = point_size * (gw->goban.top - gw->goban.bottom + 1);;
-
- if (gw->goban.display_coordinates == FALSE)
- XFillRectangle (display, gw->goban.board, gw->goban.background_gc, x, y, width, height);
- XCopyArea (display, gw->goban.board, gw->goban.picture, gw->goban.copy_gc, x, y, width, height, x, y);
-
- x = gw->goban.x_offset + point_size * (gw->goban.right + 1);
-
- if (gw->goban.display_coordinates == FALSE)
- XFillRectangle (display, gw->goban.board, gw->goban.background_gc, x, y, width, height);
- XCopyArea (display, gw->goban.board, gw->goban.picture, gw->goban.copy_gc, x, y, width, height, x, y);
- }
-
- }
-
- /****************************************************************************************************************
- */
-
- static void InitializeSize (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Position bottom = Min (gw->goban.bottom, gw->goban.top );
- Position left = Min (gw->goban.left , gw->goban.right);
- Position top = Max (gw->goban.bottom, gw->goban.top );
- Position right = Max (gw->goban.left , gw->goban.right);
- Dimension game_size = gw->goban.game_size;
- Dimension width;
- Dimension height;
-
- game_size = (game_size > 1 && game_size < 20 ) ? game_size : 19;
- bottom = (bottom > 0 && bottom < game_size) ? bottom : 1;
- left = (left > 0 && left < game_size) ? left : 1;
- top = (top > bottom && top <= game_size) ? top : game_size;
- right = (right > left && right <= game_size) ? right : game_size;
-
- width = right - left + 3;
- height = top - bottom + 3;
-
- if ((w->core.height == 0) && (w->core.width == 0)) {
- w->core.width = gw->goban.point_size * width ;
- w->core.height = gw->goban.point_size * height;
- }
-
- else
- gw->goban.point_size = Min (w->core.width / width, w->core.height / height);
-
- gw->goban.game_size = game_size;
- gw->goban.bottom = bottom;
- gw->goban.left = left;
- gw->goban.top = top;
- gw->goban.right = right;
- gw->goban.x_offset = (int) (w->core.width - gw->goban.point_size * (width + 2 * left - 2)) / 2;
- gw->goban.y_offset = (int) (w->core.height - gw->goban.point_size * (height - 2 * top - 2)) / 2;
- }
-
- /****************************************************************************************************************
- */
-
- /* ARGSUSED */
-
- static void Initialize (request, new)
- Widget request;
- Widget new;
- {
- InitializeSize (new);
- InitializePixmap (new);
- InitializeGC (new);
- InitializeCursor (new);
- DrawBoard (new);
- DrawCoordinates (new);
- GbClearBoard (new);
- }
-
- /****************************************************************************************************************
- */
-
- static void DrawPoint (w, x, y, color)
- Widget w;
- int x;
- int y;
- GbPointState color;
- {
- GobanWidget gw = (GobanWidget) w;
- Display *display = XtDisplay (w);
- unsigned int size = (unsigned int) gw->goban.point_size - 2;
- XExposeEvent event;
- int X;
- int Y;
-
- if (size > 1) {
- X = gw->goban.x_offset + gw->goban.point_size * x + 1;
- Y = gw->goban.y_offset - gw->goban.point_size * y + 1;
-
- switch (color)
- {
- case GbBlackStone :
- XFillArc (display, gw->goban.picture, gw->goban.black_bg_gc, X, Y, size, size, 0, 360 * 64);
- XDrawArc (display, gw->goban.picture, gw->goban.black_bd_gc, X, Y, size, size, 0, 360 * 64);
- XDrawArc (display, gw->goban.picture, gw->goban.black_fg_gc, X + (int) size / 6, Y + (int) size / 6,
- (size * 2) / 3, (size * 2) / 3, -15 * 64, -60 * 64);
- break;
- case GbWhiteStone :
- XFillArc (display, gw->goban.picture, gw->goban.white_bg_gc, X, Y, size, size, 0, 360 * 64);
- XDrawArc (display, gw->goban.picture, gw->goban.white_bd_gc, X, Y, size, size, 0, 360 * 64);
- XDrawArc (display, gw->goban.picture, gw->goban.white_fg_gc, X + (int) size / 6, Y + (int) size / 6,
- (size * 2) / 3, (size * 2) / 3, -15 * 64, -60 * 64);
- break;
- case GbEmptyPoint :
- XCopyArea (XtDisplay (w), gw->goban.board, gw->goban.picture, gw->goban.copy_gc,
- X, Y, gw->goban.point_size, gw->goban.point_size, X, Y);
- break;
- }
-
- if (gw->goban.auto_redisplay == TRUE && XtIsRealized (w) == TRUE) {
- event.x = X - 1;
- event.y = Y - 1;
- event.width = gw->goban.point_size;
- event.height = gw->goban.point_size;
-
- Redisplay (w, &event, (Region) NULL);
- }
- }
- }
-
- /****************************************************************************************************************
- */
-
- static void RedrawStones (w)
- Widget w;
- {
- GobanWidget gw = (GobanWidget) w;
- Boolean redisplay = gw->goban.auto_redisplay;
- Position x;
- Position y;
-
- gw->goban.auto_redisplay = FALSE;
-
- for (x = gw->goban.left; x <= gw->goban.right; x++)
- for (y = gw->goban.bottom; y <= gw->goban.top; y++) {
- if (gw->goban.points[x][y].free == 0) {
- if (gw->goban.points[x][y].black == 1)
- DrawPoint (w, x, y, GbBlackStone);
- else
- DrawPoint (w, x, y, GbWhiteStone);
- if (gw->goban.points[x][y].num > 0)
- GbSetNum (w, x, y, (int) gw->goban.points[x][y].num);
- }
-
- if (gw->goban.points[x][y].mark1 != 0 || gw->goban.points[x][y].mark2 != 0)
- GbSetMark (w, x, y, gw->goban.points[x][y].mark1, gw->goban.points[x][y].mark2);
- }
-
- gw->goban.auto_redisplay = redisplay;
-
- if (redisplay == TRUE)
- GbRedisplayBoard (w);
- }
-
- /****************************************************************************************************************
- */
-
- static void Resize (w)
- Widget w;
- {
- DestroyPixmap (w);
- DestroyGC (w);
- InitializeSize (w);
- InitializePixmap (w);
- InitializeGC (w);
- DrawBoard (w);
- DrawCoordinates (w);
- RedrawStones (w);
- }
-
- /****************************************************************************************************************
- */
-
- /* ARGSUSED */
-
- static Boolean SetValues (current, request, new)
- Widget current;
- Widget request;
- Widget new;
- {
- GobanWidget gnew = (GobanWidget) new;
- GobanWidget gcurrent = (GobanWidget) current;
- Boolean redisplay = FALSE;
-
- if (gnew->goban.point_size != gcurrent->goban.point_size)
- gnew->goban.point_size = gcurrent->goban.point_size;
-
- if (XtIsRealized (new)) {
- if (gnew->goban.cursor != gcurrent->goban.cursor) {
-
- switch (gnew->goban.cursor) {
-
- case GbCGrayStone :
- XDefineCursor (XtDisplay (new), XtWindow (new), gnew->goban.gray_cursor);
- break;
- case GbCBlackStone :
- XDefineCursor (XtDisplay (new), XtWindow (new), gnew->goban.black_cursor);
- break;
- case GbCWhiteStone :
- XDefineCursor (XtDisplay (new), XtWindow (new), gnew->goban.white_cursor);
- break;
- default :
- XFreeCursor (XtDisplay (new), gnew->goban.font_cursor );
- gnew->goban.font_cursor = XCreateFontCursor (XtDisplay (new), (unsigned int) gnew->goban.cursor);
- XDefineCursor (XtDisplay (new), XtWindow (new), gnew->goban.font_cursor);
- }
- }
- }
-
- if (gnew->goban.game_size != gcurrent->goban.game_size)
- if (gnew->goban.game_size > 1 && gnew->goban.game_size < 20) {
-
- gnew->goban.bottom = 1;
- gnew->goban.left = 1;
- gnew->goban.top = gnew->goban.game_size;
- gnew->goban.right = gnew->goban.game_size;
-
- InitializeSize (new);
- DrawBoard (new);
- DrawCoordinates (new);
- GbClearBoard (new);
-
- redisplay = TRUE;
- }
- else
- gnew->goban.game_size = gcurrent->goban.game_size;
-
- else if (gnew->goban.top != gcurrent->goban.top ||
- gnew->goban.left != gcurrent->goban.left ||
- gnew->goban.right != gcurrent->goban.right ||
- gnew->goban.bottom != gcurrent->goban.bottom) {
-
- InitializeSize (new);
- DrawBoard (new);
- DrawCoordinates (new);
- RedrawStones (new);
-
- redisplay = TRUE;
- }
-
- else if (new->core.background_pixel != current->core.background_pixel ||
- gnew->goban.foreground != gcurrent->goban.foreground ||
- gnew->goban.white_fg != gcurrent->goban.white_fg ||
- gnew->goban.white_bg != gcurrent->goban.white_bg ||
- gnew->goban.white_bd != gcurrent->goban.white_bd ||
- gnew->goban.black_fg != gcurrent->goban.black_fg ||
- gnew->goban.black_bg != gcurrent->goban.black_bg ||
- gnew->goban.black_bd != gcurrent->goban.black_bd ) {
-
- DestroyGC (new);
- InitializeGC (new);
- DrawBoard (new);
- DrawCoordinates (new);
- RedrawStones (new);
-
- redisplay = TRUE;
- }
-
- if (gnew->goban.display_coordinates != gcurrent->goban.display_coordinates) {
- DrawCoordinates (new);
-
- redisplay = TRUE;
- }
-
- return (gnew->goban.auto_redisplay == True) ? redisplay : False;
- }
-
- /****************************************************************************************************************
- */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'node.c'
- then
- echo shar: will not over-write existing file "'node.c'"
- else
- cat << \SHAR_EOF > 'node.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include "sg.h"
-
- static void bcopy (b1, b2, length)
- char *b1;
- char *b2;
- int length;
- {
- if (length > 0)
- if ((long) (b2 - b1) < 0)
- while (length-- > 0)
- *b2++ = *b1++;
-
- else {
- b2 += length;
- b1 += length;
-
- while (length-- > 0)
- *--b2 = *--b1;
- }
- }
-
- static void bzero (b, length)
- char *b;
- int length;
- {
- if (length > 0)
- while (length-- > 0)
- *b++ = '\0';
- }
-
- /*******************************************************************************************************
- *
- * Recopie la chaine <src> a la suite de la chaine <*dst>. La memoire est allouee par malloc et les
- * deux chaines sont supposees etre terminees par le caractere <end>.
- */
-
- void SG_strcat (dst, src, end)
- char **dst;
- char *src;
- char end;
- {
- char *ptr;
- int src_size = 0;
- int dst_size = 0;
-
- if ( src != NULL) { ptr = src; while (*ptr++ != end) src_size++; }
- if (*dst != NULL) { ptr = *dst; while (*ptr++ != end) dst_size++; }
-
- if (src_size > 0) {
- ptr = (char*) malloc ((unsigned) src_size + dst_size + 1);
-
- (void) bcopy (*dst, ptr , dst_size );
- (void) bcopy ( src, ptr + dst_size, src_size + 1);
-
- (void) free (*dst);
- *dst = ptr;
- }
- }
-
- /*******************************************************************************************************
- *
- * Recopie la chaine <src> a la place de la chaine *<dst>. Les deux chaines sont terminees par
- * le caractere <end>.
- */
-
- void SG_strcpy (dst, src, end)
- char **dst;
- char *src;
- char end;
- {
- char *ptr;
- int src_size = 0;
- int dst_size = 0;
-
- if ( src != NULL) { ptr = src; while (*ptr++ != end) src_size++; }
- if (*dst != NULL) { ptr = *dst; while (*ptr++ != end) dst_size++; }
-
- if (src_size == dst_size)
- (void) bcopy (src, *dst, src_size);
-
- else {
- (void) free (*dst);
- *dst = (char*) malloc ((unsigned) src_size + 1);
- (void) bcopy (src, *dst, src_size + 1);
- }
- }
-
- /*******************************************************************************************************
- *
- * Supprime le noeud <node> de l'arbre. Tous les pointeurs (up, down, right et left) sont remis
- * a NULL pour ce noeud. La valeur retournee est le noeud lui-meme : il est necessaire d'appeler
- * SG_FreeNode pour recuperer la place memoire associee et liberer les proprietes.
- */
-
- SG_NodePtr SG_RemoveNode (node)
- SG_NodePtr node;
- {
- if (node->up != NULL) {
- node->up->down = node->right;
- if (node->right != NULL)
- node->right->up = node->up;
- node->up = NULL;
- }
-
- if (node->left != NULL && node->right != NULL) {
- node->left->right = node->right;
- node->right->left = node->left;
- }
-
- else if (node->right != NULL)
- node->right->left = NULL;
-
- else if (node->left != NULL)
- node->left->right = NULL;
-
- node->left = NULL;
- node->right = NULL;
-
- return node;
- }
-
- /*******************************************************************************************************
- *
- * Libere le noeud <node>. Cette fonction est appelee recursivement sur les fils et les freres
- * de ce noeud. La liste des proprietes est liberee par la meme occasion
- */
-
- void SG_FreeNode (node)
- SG_NodePtr node;
- {
- SG_PropertyPtr property;
- SG_PropertyPtr next_property;
- SG_NodePtr next_node;
-
- free_node :
-
- if (node != NULL) {
- if (node->right != NULL)
- SG_FreeNode (node->right);
-
- next_property = node->property;
-
- while (next_property != NULL) {
- property = next_property;
- next_property = property->next;
-
- switch (property->id) {
- case SG_Letters :
- case SG_Comment :
- case SG_GameComment :
- case SG_GameName :
- case SG_nodeName :
- case SG_EVent :
- case SG_ROund :
- case SG_DaTe :
- case SG_PlaCe :
- case SG_REsult :
- case SG_USer :
- case SG_TiMe :
- case SG_SOurce :
- case SG_BlackRank :
- case SG_WhiteRank :
- case SG_BlackSpec :
- case SG_WhiteSpec :
- case SG_HAndicap :
- case SG_KoMi :
- case SG_PlayerBlack :
- case SG_PlayerWhite :
- case SG_BlackLeft :
- case SG_WhiteLeft :
- free ((char *) property->data.pvalue);
- break;
- }
-
- (void) free ((char *) property);
- }
-
- (void) free ((char *) node->setup);
-
- next_node = node->down;
- (void) free ((char *) node);
-
- node = next_node;
- goto free_node;
- }
- }
-
- /*******************************************************************************************************
- *
- * Retourne un nouveau noeud alloue par malloc. Tous les champs sont remis a zero.
- */
-
- static SG_NodePtr make_node ()
- {
- SG_NodePtr node;
-
- node = (SG_NodePtr) malloc ((unsigned) sizeof (SG_Node));
-
- node->num = -1;
- node->color = SG_EmptyPoint;
- node->x = 0;
- node->y = 0;
- node->player = SG_EmptyPoint;
- node->setup = NULL;
- node->property = NULL;
- node->up = NULL;
- node->down = NULL;
- node->left = NULL;
- node->right = NULL;
-
- return node;
- }
-
- /*******************************************************************************************************
- *
- */
-
- SG_NodePtr SG_MakeNode (node, type)
- SG_NodePtr node;
- int type;
- {
- SG_NodePtr new = NULL;
-
- switch (type) {
-
- case SG_Event :
- new = make_node ();
-
- if (node != NULL) {
- do {
- while (node->up != NULL)
- node = node->up;
- while (node->left != NULL)
- node = node->left;
- } while (node->up != NULL);
-
- while (node->right != NULL)
- node = node->right;
-
- node->right = new;
- new->left = node;
- }
-
- new->type = SG_EventType;
- break;
-
- case SG_Move :
- case SG_Diagram :
- new = make_node ();
-
- node->down = new;
- new->up = node;
-
- if (type == SG_Move)
- new->type = SG_MoveType;
- else
- new->type = SG_DiagramType;
- break;
-
- case SG_VariationMove :
- case SG_VariationDiagram :
-
- new = make_node ();
-
- while (node->right != NULL)
- node = node->right;
-
- node->right = new;
- new->left = node;
-
- if (type == SG_VariationMove)
- new->type = SG_MoveType;
- else
- new->type = SG_DiagramType;
-
- break;
- }
-
- return new;
- }
-
- /*******************************************************************************************************
- *
- */
-
- SG_PropertyPtr SG_GetProperty (node, id)
- SG_NodePtr node;
- int id;
- {
- SG_PropertyPtr property = node->property;
-
- while (property != NULL) {
- if (property->id == id)
- break;
- property = property->next;
- }
-
- return property;
- }
-
- /*******************************************************************************************************
- *
- */
-
- void SG_MakeProperty (node, id, value)
- SG_NodePtr node;
- int id;
- long value;
- {
- SG_PropertyPtr property;
-
- property = SG_GetProperty (node, id);
-
- if (property == NULL) {
- if (node->property != NULL) {
- property = node->property;
-
- while (property->next != NULL)
- property = property->next;
-
- property->next = (SG_PropertyPtr) malloc ((unsigned) sizeof (SG_Property));
- property = property->next;
- }
-
- else
- property = node->property = (SG_PropertyPtr) malloc ((unsigned) sizeof (SG_Property));
-
- (void) bzero ((char *) property, sizeof (SG_Property));
- }
-
- property->id = id;
-
- switch (id) {
-
- case SG_unVieW :
- case SG_ko :
-
- case SG_KO :
- property->data.ivalue = value;
- break;
-
- case SG_SiZe :
- case SG_VieW :
- property->data.pvalue = (unsigned char *) value;
- break;
-
- case SG_AddBlack :
- case SG_AddWhite :
- case SG_AddEmpty :
- case SG_Letters :
- case SG_Marked :
- SG_strcat ((char **) &property->data.pvalue, (char *) value, SG_EOS);
- break;
-
- case SG_Comment :
- case SG_GameComment :
- SG_strcat ((char **) &property->data.pvalue, (char *) value, '\0');
- break;
-
- case SG_GameName :
- case SG_nodeName :
- case SG_EVent :
- case SG_ROund :
- case SG_DaTe :
- case SG_PlaCe :
- case SG_REsult :
- case SG_USer :
- case SG_TiMe :
- case SG_SOurce :
- case SG_BlackRank :
- case SG_WhiteRank :
- case SG_BlackSpec :
- case SG_WhiteSpec :
- case SG_HAndicap :
- case SG_KoMi :
- case SG_PlayerBlack :
- case SG_PlayerWhite :
- case SG_BlackLeft :
- case SG_WhiteLeft :
- SG_strcpy ((char **) &property->data.pvalue, (char *) value, '\0');
- break;
- }
- }
-
- /*******************************************************************************************************
- *
- */
-
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'sg.c'
- then
- echo shar: will not over-write existing file "'sg.c'"
- else
- cat << \SHAR_EOF > 'sg.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include "sg.h"
-
- SG_KWData sg_keywords[] = {
- { "" , "" , SG_Illegal , 0 , },
- { "B" , "Black" , SG_Black , SG_MoveType , },
- { "W" , "White" , SG_White , SG_MoveType , },
- { "C" , "Comment" , SG_Comment , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "N" , "nodeName" , SG_nodeName , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "V" , "nodeValue" , SG_nodeValue , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "CH" , "CHeck" , SG_CHeck , SG_MoveType , },
- { "GB" , "GoodBlack" , SG_GoodBlack , SG_MoveType , },
- { "GW" , "GoodWhite" , SG_GoodWhite , SG_MoveType , },
- { "TE" , "TEsuji" , SG_TEsuji , SG_MoveType , },
- { "BM" , "BadMove" , SG_BadMove , SG_MoveType , },
- { "BL" , "BlackLeft" , SG_BlackLeft , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "WL" , "WhiteLeft" , SG_WhiteLeft , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "FG" , "FiGure" , SG_FiGure , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "AB" , "AddBlack" , SG_AddBlack , SG_EventType | SG_DiagramType , },
- { "AW" , "AddWhite" , SG_AddWhite , SG_EventType | SG_DiagramType , },
- { "AE" , "AddEmpty" , SG_AddEmpty , SG_EventType | SG_DiagramType , },
- { "PL" , "PLayer" , SG_PLayer , SG_EventType | SG_DiagramType , },
- { "GN" , "GameName" , SG_GameName , SG_EventType , },
- { "GC" , "GameComment" , SG_GameComment , SG_EventType , },
- { "EV" , "EVent" , SG_EVent , SG_EventType , },
- { "RO" , "ROund" , SG_ROund , SG_EventType , },
- { "DT" , "DaTe" , SG_DaTe , SG_EventType , },
- { "PC" , "PlaCe" , SG_PlaCe , SG_EventType , },
- { "PB" , "PlayerBlack" , SG_PlayerBlack , SG_EventType , },
- { "PW" , "PlayerWhite" , SG_PlayerWhite , SG_EventType , },
- { "RE" , "REsult" , SG_REsult , SG_EventType , },
- { "US" , "USer" , SG_USer , SG_EventType , },
- { "TM" , "TiMe" , SG_TiMe , SG_EventType , },
- { "SO" , "SOurce" , SG_SOurce , SG_EventType , },
- { "GM" , "GaMe" , SG_GaMe , SG_EventType , },
- { "SZ" , "SiZe" , SG_SiZe , SG_EventType , },
- { "VW" , "VieW" , SG_VieW , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "BS" , "BlackSpec" , SG_BlackSpec , SG_EventType , },
- { "WS" , "WhiteSpec" , SG_WhiteSpec , SG_EventType , },
- { "EL" , "EvaLuation" , SG_EvaLuation , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "EX" , "EXpected" , SG_EXpected , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "SL" , "SeLected" , SG_SeLected , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "M" , "Marked" , SG_Marked , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "L" , "Letters" , SG_Letters , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "BR" , "BlackRank" , SG_BlackRank , SG_EventType , },
- { "WR" , "WhiteRank" , SG_WhiteRank , SG_EventType , },
- { "HA" , "HAndicap" , SG_HAndicap , SG_EventType , },
- { "KM" , "KoMi" , SG_KoMi , SG_EventType , },
- { "TB" , "TerritoryBlack" , SG_TerritoryBlack , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "TW" , "TerritoryWhite" , SG_TerritoryWhite , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "SC" , "SeCure" , SG_SeCure , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "RG" , "ReGion" , SG_ReGion , SG_EventType | SG_MoveType | SG_DiagramType , },
- { "KO" , "KO" , SG_KO , SG_MoveType , },
- { "" , "" , SG_Illegal , 0 , },
- };
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'read.c'
- then
- echo shar: will not over-write existing file "'read.c'"
- else
- cat << \SHAR_EOF > 'read.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include "sg.h"
-
- static int size = 19;
-
- /*******************************************************************************************************
- */
-
- static int read_int (i, file)
- int *i;
- FILE *file;
- {
- int result = SG_OK;
- int ch = ' ';
- int j = 0;
-
- while (ch != '[' && ch != EOF) ch = getc (file);
- if (ch == EOF) return SG_EOFERR;
-
- ch = getc (file);
- if (! isdigit (ch)) goto error;
-
- while (isdigit (ch)) {
- j = 10 * j + ch - '0';
- ch = getc (file);
- }
- *i = j;
- goto ok;
-
- error :
- result = SG_NDGERR;
-
- ok :
- while (ch != ']' && ch != EOF) ch = getc (file);
- return result;
- }
-
- /*******************************************************************************************************
- *
- */
-
- static int read_color (color, file)
- unsigned char *color;
- FILE *file;
- {
- int result = SG_OK;
- int ch = ' ';
-
- while (ch != '[' && ch != EOF) ch = getc (file);
- if (ch == EOF) return SG_EOFERR;
-
- ch = getc (file);
- switch (ch) {
- case 'B' : case 'b' : *color = SG_BlackStone; goto ok;
- case 'W' : case 'w' : *color = SG_WhiteStone; goto ok;
- }
-
- result = SG_NCLERR;
-
- ok :
- while (ch != ']' && ch != EOF) ch = getc (file);
- return result;
- }
-
- /*******************************************************************************************************
- */
-
- static int read_stone (x, y, file)
- unsigned char *x;
- unsigned char *y;
- FILE *file;
- {
- int result = SG_OK;
- int ch = ' ';
-
- while (ch != '[' && ch != EOF) ch = getc (file);
- if (ch == EOF) return SG_EOFERR;
-
- ch = getc (file);
- if (! islower (ch)) goto error;
- *x = ch - 'a' + 1;
-
- ch = getc (file);
- if (! islower (ch)) goto error;
- *y = size + 1 - (ch - 'a' + 1);
-
- if (*y == 20 || *x == 20)
- *x = *y = 0;
-
- goto ok;
-
- error :
- result = SG_NSTERR;
-
- ok :
- while (ch != ']' && ch != EOF) ch = getc (file);
- return result;
- }
-
- /*******************************************************************************************************
- */
-
- static int read_stones (color, dst, file)
- unsigned char color;
- unsigned char **dst;
- FILE *file;
- {
- unsigned char stones[361 * 2];
- unsigned char *pos = stones;
- int ch = ' ';
-
- do {
- if (read_stone (pos, pos + 1, file) == SG_OK) {
- *pos++ |= color;
- *pos++ |= color;
- }
-
- do ch = getc (file);
- while (isspace (ch) && ch != EOF);
-
- if (ch != EOF)
- (void) ungetc (ch, file);
-
- } while (ch == '[');
-
- if (pos != stones) {
- *pos++ = SG_EOS;
- SG_strcat ((char **) dst, (char *) stones, SG_EOS);
- return SG_OK;
- }
-
- else
- return SG_NSTERR;
- }
-
- /*******************************************************************************************************
- */
-
- static int read_text (dst, file, add)
- unsigned char **dst;
- FILE *file;
- int add;
- {
- char text[5010];
- char *ptr = text;
- int ch = ' ';
-
- while (ch != '[' && ch != EOF) ch = getc (file);
- if (ch == EOF) return SG_NCTERR;
-
- while (ch != ']' && ch != EOF) {
- ch = getc (file);
-
- if ((unsigned) (ptr - text) < 5000) {
- if (ch == '\\') {
- *ptr = getc (file);
-
- switch (*ptr) {
- case 'n' : *ptr = '\n'; break;
- case 't' : *ptr = '\t'; break;
- }
-
- ptr++;
- }
-
- else
- *ptr++ = ch;
- }
-
- else {
- *ptr++ = '.';
- *ptr++ = '.';
- *ptr++ = '.';
- }
- }
-
- ptr--;
-
- if (ptr != text) {
- *ptr++ = '\0';
-
- if (add != 0)
- SG_strcat ((char **) dst, (char *) text, '\0');
- else
- SG_strcpy ((char **) dst, (char *) text, '\0');
- }
-
- return SG_OK;
- }
-
- /*******************************************************************************************************
- */
-
- static void read_property (node, cmd, file)
- SG_NodePtr node;
- char *cmd;
- FILE *file;
- {
- int id;
- SG_PropertyPtr property;
- char top;
- char left;
- char bottom;
- char right;
- unsigned char x;
- unsigned char y;
- int i;
- long value;
-
- for (id = 0; id < SG_MaxID; id++)
- if (strcmp (cmd, sg_keywords[id].keyword) == 0)
- break;
-
- id = sg_keywords[id].id;
-
- if ((id == SG_Black || id == SG_White) && node->type == SG_DiagramType) {
- if (node->setup == NULL)
- node->type = SG_MoveType;
-
- else
- id = (id == SG_Black) ? SG_AddBlack : SG_AddWhite;
- }
-
- if (node->type == SG_DiagramType || node->type == SG_EventType) {
- if (id == SG_Black) {
- id = SG_AddBlack;
- if (node->player == SG_EmptyPoint) node->player = SG_WhiteStone;
- }
-
- if (id == SG_White) {
- id = SG_AddWhite;
- if (node->player == SG_EmptyPoint) node->player = SG_BlackStone;
- }
- }
-
- if ((node->type & sg_keywords[id].node_id) != 0)
- switch (id) {
-
- case SG_SiZe :
- if (read_int (&i, file) == SG_OK) {
- size = i;
- SG_MakeProperty (node, id, size);
- }
- break;
-
- case SG_Black :
- if (read_stone (&x, &y, file) == SG_OK) {
- node->x = x;
- node->y = y;
- node->color = SG_BlackStone;
- }
- break;
-
- case SG_White :
- if (read_stone (&x, &y, file) == SG_OK) {
- node->x = x;
- node->y = y;
- node->color = SG_WhiteStone;
- }
- break;
-
- case SG_AddBlack :
- (void) read_stones (SG_SETB, &node->setup, file);
- break;
-
- case SG_AddWhite :
- (void) read_stones (SG_SETW, &node->setup, file);
- break;
-
- case SG_AddEmpty :
- (void) read_stones (SG_SETE, &node->setup, file);
- break;
-
- case SG_VieW :
- if (read_stone (&x, &y, file) == SG_OK) {
- left = x;
- top = y;
-
- if (read_stone (&x, &y, file) == SG_OK) {
- right = x;
- bottom = y;
- value = ((long) top << 24) + ((long) left << 16) + ((long) bottom << 8) + (long) right;
-
- SG_MakeProperty (node, id, value);
- }
- }
- break;
-
- case SG_Letters :
- case SG_Marked :
- SG_MakeProperty (node, id, NULL);
- property = SG_GetProperty (node, id);
- (void) read_stones (SG_SETE, &property->data.pvalue, file);
- break;
-
- case SG_Comment :
- case SG_GameComment :
- SG_MakeProperty (node, id, NULL);
- property = SG_GetProperty (node, id);
- (void) read_text (&property->data.pvalue, file, 1);
- break;
-
- case SG_PLayer :
- (void) read_color (&x, file);
- node->player = x;
- break;
-
- case SG_GameName :
- case SG_nodeName :
- case SG_EVent :
- case SG_ROund :
- case SG_DaTe :
- case SG_PlaCe :
- case SG_REsult :
- case SG_USer :
- case SG_TiMe :
- case SG_SOurce :
- case SG_BlackRank :
- case SG_WhiteRank :
- case SG_BlackSpec :
- case SG_WhiteSpec :
- case SG_HAndicap :
- case SG_KoMi :
- case SG_PlayerBlack :
- case SG_PlayerWhite :
- case SG_BlackLeft :
- case SG_WhiteLeft :
- SG_MakeProperty (node, id, NULL);
- property = SG_GetProperty (node, id);
- (void) read_text (&property->data.pvalue, file, 0);
- break;
- }
- }
-
- /*******************************************************************************************************
- */
-
- static SG_NodePtr root;
-
- static SG_NodePtr read_node (node, var, file, level)
- SG_NodePtr node;
- int var;
- FILE *file;
- int level;
- {
- char cmd[3];
- int ch;
- int len = 0;
- int no_node = 1;
- int nb_var = 0;
-
- do {
- ch = getc (file);
-
- switch (ch) {
-
- case ';' :
- if (level != 0) {
- if (node == NULL) {
- node = SG_MakeNode (root, SG_Event);
- if (root == NULL)
- root = node;
- }
-
- else if (var-- == 1)
- node = SG_MakeNode (node, SG_VariationDiagram);
-
- else
- node = SG_MakeNode (node, SG_Diagram);
-
- no_node = 0;
- len = 0;
- }
- break;
-
- case '(' :
- if (level == 0)
- node = read_node ((SG_NodePtr) NULL, 0, file, level + 1);
- else if (nb_var++ == 0 || node->down == NULL)
- (void) read_node (node, 0, file, level + 1);
- else
- (void) read_node (node->down, 1, file, level + 1);
-
- len = 0;
- break;
-
- case EOF :
- case ')' :
- return node;
-
- case '[' :
- if (len > 0 && no_node == 0) {
- (void) ungetc (ch, file);
- cmd[len++] = '\0';
-
- read_property (node, cmd, file);
- }
-
- else
- while (ch != ']' && ch != EOF) ch = getc (file);
-
- len = 0;
- break;
-
- default :
- if (isupper (ch) && len < 2)
- cmd[len++] = ch;
- }
-
- } while (ch != EOF);
-
- return node;
- }
-
- /*******************************************************************************************************
- */
-
- SG_NodePtr SG_ReadTree (file)
- FILE *file;
- {
- size = 19;
- root = NULL;
-
- (void) read_node ((SG_NodePtr) NULL, 0, file, 0);
-
- return root;
- }
-
- /*******************************************************************************************************
- */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'write.c'
- then
- echo shar: will not over-write existing file "'write.c'"
- else
- cat << \SHAR_EOF > 'write.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include "sg.h"
-
- #define PrintKeyword(id) (short_print == 0 ? sg_keywords[id].print : sg_keywords[id].keyword)
- #define Newline(file) { if (short_print == 0) if (fprintf (file, "\n") == EOF) return EOF; }
-
- static int size = 19;
- static int short_print = 0;
-
- /*******************************************************************************************************
- */
-
- static int write_node (node, var, file, level)
- SG_NodePtr node;
- int var;
- FILE *file;
- int level;
- {
- SG_PropertyPtr property;
- unsigned char *ptr;
- unsigned char color;
- int x;
- int y;
-
- if (node != NULL) {
-
- if (node->right != NULL && var == 1)
- do {
- if (write_node (node, 0, file, level) == EOF)
- return EOF;
-
- node = node->right;
- } while (node != NULL);
-
- else {
- if (fprintf (file, "(") == EOF)
- return EOF;
- Newline (file);
-
- if (fprintf (file, ";") == EOF)
- return EOF;
- Newline (file);
-
- if (level == 0) {
- if (fprintf (file, "%s[1]", PrintKeyword (SG_GaMe)) == EOF)
- return EOF;
- Newline (file);
- }
-
- goto sequence1;
-
- sequence :
-
- if (fprintf (file, ";") == EOF)
- return EOF;
- Newline (file);
-
- sequence1 :
-
- switch (node->type) {
-
- case SG_EventType :
- case SG_DiagramType :
-
- if ((ptr = node->setup) != NULL) {
-
- color = ~(*ptr & 0xc0);
-
- while (*ptr != SG_EOS) {
- if ((*ptr & 0xc0) != color &&
- ! ((*ptr & 0xc0) == SG_SETEB && color == SG_SETEW) &&
- ! ((*ptr & 0xc0) == SG_SETEW && color == SG_SETEB)) {
- color = *ptr & 0xc0;
-
- if (ptr != node->setup) {
- Newline (file);
- }
-
- switch (color) {
- case SG_SETB :
- if (fprintf (file, "%s", PrintKeyword (SG_AddBlack)) == EOF)
- return EOF;
- break;
- case SG_SETW :
- if (fprintf (file, "%s", PrintKeyword (SG_AddWhite)) == EOF)
- return EOF;
- break;
- case SG_SETEB :
- case SG_SETEW :
- if (fprintf (file, "%s", PrintKeyword (SG_AddEmpty)) == EOF)
- return EOF;
- break;
- }
- }
-
- x = *ptr++ & 0x3f;
- y = *ptr++ & 0x3f;
-
- if (fprintf (file, "[%c%c]", 'a' - 1 + x , 'a' + size - y) == EOF)
- return EOF;
-
- }
-
- Newline (file);
- }
-
- if (fprintf (file, "%s[%c]",
- PrintKeyword (SG_PLayer),
- (node->player == SG_WhiteStone) ? 'W' : 'B')
- == EOF)
- return EOF;
- Newline (file);
-
- break;
-
- case SG_MoveType :
- if (node->x == 0 && node->y == 0) {
- if (fprintf (file, "%s[tt]",
- PrintKeyword ((node->color == SG_BlackStone) ? SG_Black : SG_White))
- == EOF)
- return EOF;
- Newline (file);
- }
-
- else {
- if (fprintf (file, "%s[%c%c]",
- PrintKeyword ((node->color == SG_BlackStone) ? SG_Black : SG_White),
- 'a' - 1 + node->x,
- 'a' + size - node->y)
- == EOF)
- return EOF;
- Newline (file);
- }
-
- break;
- }
-
- property = node->property;
-
- while (property != NULL) {
- switch (property->id) {
-
- case SG_VieW :
- if (fprintf (file, "%s[%c%c][%c%c]",
- PrintKeyword (SG_VieW),
- 'a' - 1 + ((property->data.ivalue >> 16) & 0xff),
- 'a' + size - ((property->data.ivalue >> 24) & 0xff),
- 'a' - 1 + ((property->data.ivalue ) & 0xff),
- 'a' + size - ((property->data.ivalue >> 8) & 0xff))
- == EOF)
- return EOF;
- Newline (file);
- break;
-
- case SG_SiZe :
- size = property->data.ivalue;
- if (fprintf (file, "%s[%d]",
- PrintKeyword (SG_SiZe),
- property->data.ivalue)
- == EOF)
- return EOF;
- Newline (file);
- break;
-
- case SG_KO :
- if (fprintf (file, "%s[%c%c]",
- PrintKeyword (SG_KO),
- 'a' - 1 + ((property->data.ivalue >> 8) & 0x3f),
- 'a' + size - (property->data.ivalue & 0x3f))
- == EOF)
- return EOF;
- Newline (file);
- break;
-
- case SG_Comment :
- case SG_GameName :
- case SG_GameComment :
- case SG_nodeName :
- case SG_EVent :
- case SG_ROund :
- case SG_DaTe :
- case SG_PlaCe :
- case SG_REsult :
- case SG_USer :
- case SG_TiMe :
- case SG_SOurce :
- case SG_BlackRank :
- case SG_WhiteRank :
- case SG_BlackSpec :
- case SG_WhiteSpec :
- case SG_HAndicap :
- case SG_KoMi :
- case SG_PlayerBlack :
- case SG_PlayerWhite :
- case SG_BlackLeft :
- case SG_WhiteLeft :
-
- if ((ptr = property ->data.pvalue) != NULL && strcmp ((char *) ptr, "") != 0) {
- if (fprintf (file, "%s[", PrintKeyword (property->id)) == EOF)
- return EOF;
-
- while (*ptr != '\0') {
- if (*ptr == ']')
- if (putc ('\\', file) == EOF) return EOF;
- if (putc ((char) *ptr, file) == EOF) return EOF;
- ptr++;
- }
-
- if (fprintf (file, "]") == EOF) return EOF; Newline (file);
- }
- break;
-
- case SG_Letters :
- case SG_Marked :
- if ((ptr = property->data.pvalue) != NULL) {
- if (fprintf (file, "%s",
- PrintKeyword (property->id))
- == EOF)
- return EOF;
-
- while (*ptr != SG_EOS) {
- x = *ptr++ & 0x3f;
- y = *ptr++ & 0x3f;
-
- if (x != 0 || y != 0)
- if (fprintf (file, "[%c%c]", 'a' - 1 + x , 'a' + size - y) == EOF)
- return EOF;
- }
-
- Newline (file);
- }
- break;
- }
-
- property = property->next;
- }
-
- if (node->down != NULL) {
- node = node->down;
-
- if (node->right != NULL) {
- if (write_node (node, 1, file, level + 1) == EOF)
- return EOF;
- }
- else
- goto sequence;
- }
-
- if (fprintf (file, ")") == EOF)
- return EOF;
- Newline (file);
- }
- }
-
- return 0;
- }
-
- /*******************************************************************************************************
- */
-
- int SG_WriteTree (node, file, shrt)
- SG_NodePtr node;
- FILE *file;
- int shrt;
- {
- short_print = shrt;
- size = 19;
-
- return write_node (node, 1, file, 0);
- }
-
- /*******************************************************************************************************
- */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'play.c'
- then
- echo shar: will not over-write existing file "'play.c'"
- else
- cat << \SHAR_EOF > 'play.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include "xgoban.h"
-
- static int size = 19;
- static int board[21][21];
- static int tmp_board[21][21];
-
- static int x_ko = 0;
- static int y_ko = 0;
- static int last_player;
-
- static long mark = 0;
- static long marks[21][21];
-
- /*******************************************************************************************************
- *
- * Recopie le goban <src> dans <dst>. Utile pour faire la difference de deux positions et
- * etablir les proprietes AddBlack, AddWhite et AddEmtpy.
- */
-
- static void copyBoard (src, dst)
- int src[21][21];
- int dst[21][21];
- {
- int x;
- int y;
-
- for (x = 0; x < size + 2; x++)
- for (y = 0; y < size + 2; y++)
- dst[x][y] = src[x][y];
- }
-
- /*******************************************************************************************************
- *
- * Compte les libertes d'une chaine.
- */
-
- static int countLiberty (board, x, y, color)
- int board[21][21];
- int x;
- int y;
- int color;
- {
- if (marks[x][y] != mark) {
- marks[x][y] = mark;
-
- if (board[x][y] == SG_EmptyPoint) return 1;
- if (board[x][y] == SG_Border ) return 0;
- if (board[x][y] != color ) return 0;
-
- return (countLiberty (board, x - 1, y, color) +
- countLiberty (board, x + 1, y, color) +
- countLiberty (board, x, y - 1, color) +
- countLiberty (board, x, y + 1, color));
- }
-
- return 0;
- }
-
- /*******************************************************************************************************
- *
- * Supprime une chaine du goban.
- */
-
- static void removeString (board, x, y, color)
- int board[21][21];
- int x;
- int y;
- int color;
- {
- if (board[x][y] == color) {
- board[x][y] = SG_EmptyPoint;
-
- removeString (board, x + 1, y, color);
- removeString (board, x - 1, y, color);
- removeString (board, x, y + 1, color);
- removeString (board, x, y - 1, color);
- }
- }
-
- /*******************************************************************************************************
- *
- * Fait la difference entre deux positions et construit la liste des pierres a poser ou enlever.
- * On distingue EB et EW pour que cette propriete soit reversible.
- */
-
- static void getSetup (dst, old, new)
- unsigned char **dst;
- int old[21][21];
- int new[21][21];
- {
- int x;
- int y;
- unsigned char setup[361 * 2];
- unsigned char *ptr = setup;
-
- for (x = 1; x < size + 1; x++)
- for (y = 1; y < size + 1; y++)
- if (new[x][y] != old[x][y])
- if (old[x][y] == SG_BlackStone) {
- *ptr++ = SG_SETEB | ((unsigned char) x & 0x3f);
- *ptr++ = SG_SETEB | ((unsigned char) y & 0x3f);
- }
-
- else if (old[x][y] == SG_WhiteStone) {
- *ptr++ = SG_SETEW | ((unsigned char) x & 0x3f);
- *ptr++ = SG_SETEW | ((unsigned char) y & 0x3f);
- }
-
- for (x = 1; x < size + 1; x++)
- for (y = 1; y < size + 1; y++)
- if (new[x][y] != old[x][y])
- if (new[x][y] == SG_BlackStone) {
- *ptr++ = SG_SETB | ((unsigned char) x & 0x3f);
- *ptr++ = SG_SETB | ((unsigned char) y & 0x3f);
- }
-
- for (x = 1; x < size + 1; x++)
- for (y = 1; y < size + 1; y++)
- if (new[x][y] != old[x][y])
- if (new[x][y] == SG_WhiteStone) {
- *ptr++ = SG_SETW | ((unsigned char) x & 0x3f);
- *ptr++ = SG_SETW | ((unsigned char) y & 0x3f);
- }
-
- if (ptr != setup) {
- *ptr++ = SG_EOS;
- SG_strcpy (dst, setup, SG_EOS);
- }
- }
-
- /*******************************************************************************************************
- *
- * Quelques fonctions pour editer des diagrames.
- */
-
- void StartDiagram ()
- {
- copyBoard (board, tmp_board);
- }
-
- void AddStone (x, y, color)
- int x;
- int y;
- int color;
- {
- board[x][y] = color;
- }
-
- unsigned char *EndDiagram ()
- {
- unsigned char *ptr = NULL;
-
- getSetup (&ptr, tmp_board, board);
- copyBoard (tmp_board, board);
-
- return ptr;
- }
-
- /*******************************************************************************************************
- */
-
- int Play (node)
- SG_NodePtr node;
- {
- SG_PropertyPtr property;
- SG_NodePtr tmp;
- unsigned char *ptr;
- int x;
- int y;
- int color;
- int prisoner;
- int lib;
-
- if (node != NULL)
- switch (node->type) {
-
- case SG_EventType :
- size = 19;
- property = node->property;
-
- while (property != NULL) {
- if (property->id == SG_SiZe)
- if (property->data.ivalue > 1 && property->data.ivalue < 20)
- size = property->data.ivalue;
-
- property = property->next;
- }
-
- for (x = 0; x < size + 2; x++)
- for (y = 0; y < size + 2; y++)
- board[x][y] = (x == 0 || y == 0 || x == size + 1 || y == size + 1) ?
- SG_Border : SG_EmptyPoint;
-
- case SG_DiagramType :
-
- node->num = 0;
-
- if (node->setup != NULL) {
- copyBoard (board, tmp_board);
-
- ptr = node->setup;
-
- while (*ptr != SG_EOS) {
- color = (int) (*ptr & 0xc0);
- x = (int) (*ptr++ & 0x3f);
- y = (int) (*ptr++ & 0x3f);
-
- switch (color) {
- case SG_SETB : board[x][y] = SG_BlackStone; break;
- case SG_SETW : board[x][y] = SG_WhiteStone; break;
- case SG_SETEB :
- case SG_SETEW : board[x][y] = SG_EmptyPoint; break;
- }
-
- }
-
- getSetup (&node->setup, tmp_board, board);
- }
-
- x_ko = y_ko = 0;
- break;
-
- case SG_MoveType :
-
- if (node->num == -1) {
- tmp = node;
- while (tmp->left != NULL) tmp = tmp->left;
- tmp = tmp->up;
-
- if (tmp != NULL)
- node->num = tmp->num + 1;
- }
-
- x = node->x;
- y = node->y;
- color = node->color;
- node->player = (node->color == SG_BlackStone) ? SG_WhiteStone : SG_BlackStone;
-
- if ((x_ko != 0 || y_ko != 0) && color != last_player)
- SG_MakeProperty (node, SG_ko, (last_player << 16) + (x_ko << 8) + y_ko);
-
- if (x == 0 && y == 0) {
- x_ko = y_ko = 0;
- return SG_OK;
- }
-
- if (board[x][y] != SG_EmptyPoint)
- return SG_PlayIllegal;
-
- if (x == x_ko && y == y_ko && color != last_player)
- return SG_PlayKo;
-
- board[x][y] = color;
-
- prisoner = 0;
- color = (color == SG_BlackStone) ? SG_WhiteStone : SG_BlackStone;
-
- mark++; if (board[x + 1][y] == color && countLiberty (board, x + 1, y, color) == 0) prisoner |= 1;
- mark++; if (board[x - 1][y] == color && countLiberty (board, x - 1, y, color) == 0) prisoner |= 2;
- mark++; if (board[x][y + 1] == color && countLiberty (board, x, y + 1, color) == 0) prisoner |= 4;
- mark++; if (board[x][y - 1] == color && countLiberty (board, x, y - 1, color) == 0) prisoner |= 8;
-
- mark++;
- if ((lib = countLiberty (board, x, y, board[x][y])) == 0 && prisoner == 0) {
- board[x][y] = SG_EmptyPoint;
- return SG_PlaySuicide;
- }
-
- x_ko = y_ko = 0;
-
- if (prisoner != 0) {
- copyBoard (board, tmp_board);
-
- if (prisoner & 1) removeString (board, x + 1, y, color);
- if (prisoner & 2) removeString (board, x - 1, y, color);
- if (prisoner & 4) removeString (board, x, y + 1, color);
- if (prisoner & 8) removeString (board, x, y - 1, color);
-
- getSetup (&node->setup, tmp_board, board);
-
- ptr = node->setup;
-
- prisoner = 0;
- while (*ptr != SG_EOS) {
- prisoner++;
- ptr += 2;
- }
-
- if (prisoner == 1 && lib == 0 &&
- board[x + 1][y] != board[x][y] &&
- board[x - 1][y] != board[x][y] &&
- board[x][y + 1] != board[x][y] &&
- board[x][y - 1] != board[x][y]) {
-
- x_ko = (int) (*node->setup & 0x3f);
- y_ko = (int) (*(node->setup + 1) & 0x3f);
-
- SG_MakeProperty (node, SG_KO, (x_ko << 8) + y_ko);
- }
- }
-
- last_player = (int) node->color;
- break;
- }
-
- return SG_OK;
- }
-
- /*******************************************************************************************************
- */
-
- void Unplay (node)
- SG_NodePtr node;
- {
- SG_PropertyPtr property;
- unsigned char *ptr;
- int x;
- int y;
- int color;
-
- if (node != NULL)
- switch (node->type) {
-
- case SG_EventType :
- size = 19;
-
- for (x = 0; x < size + 2; x++)
- for (y = 0; y < size + 2; y++)
- board[x][y] = (x == 0 || y == 0 || x == size + 1 || y == size + 1) ?
- SG_Border : SG_EmptyPoint;
-
- case SG_DiagramType :
-
- if (node->setup != NULL) {
-
- ptr = node->setup;
-
- while (*ptr != SG_EOS) {
- color = (int) (*ptr & 0xc0);
- x = (int) (*ptr++ & 0x3f);
- y = (int) (*ptr++ & 0x3f);
-
- switch (color) {
- case SG_SETEB : board[x][y] = SG_BlackStone; break;
- case SG_SETEW : board[x][y] = SG_WhiteStone; break;
- case SG_SETB :
- case SG_SETW : board[x][y] = SG_EmptyPoint; break;
- }
- }
- }
- break;
-
- case SG_MoveType :
- x_ko = y_ko = 0;
- last_player = SG_EmptyPoint;
-
- property = node->property;
-
- while (property != NULL) {
- if (property->id == SG_ko) {
- last_player = (int) ( property->data.ivalue >> 16);
- x_ko = (int) ((property->data.ivalue >> 8) & 0x3f);
- y_ko = (int) ( property->data.ivalue & 0x3f);
- break;
- }
-
- property = property->next;
- }
-
- x = (int) node->x;
- y = (int) node->y;
-
- if (x == 0 && y == 0)
- break;
-
- board[x][y] = SG_EmptyPoint;
-
- if (node->setup != NULL) {
- ptr = node->setup;
- color = (node->color == SG_BlackStone) ? SG_WhiteStone : SG_BlackStone;
-
- while (*ptr != SG_EOS) {
- x = (int) (*ptr++ & 0x3f);
- y = (int) (*ptr++ & 0x3f);
-
- board[x][y] = color;
- }
- }
- break;
- }
- }
-
- /*******************************************************************************************************
- */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'event.c'
- then
- echo shar: will not over-write existing file "'event.c'"
- else
- cat << \SHAR_EOF > 'event.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include <stdio.h>
- #include <ctype.h>
-
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/StringDefs.h>
-
- #include <X11/Xaw/Command.h>
- #include <X11/Xaw/Form.h>
- #include <X11/Xaw/Label.h>
- #include <X11/Xaw/AsciiText.h>
-
- #include "Goban.h"
- #include "xgoban.h"
-
- static Widget i_top;
- static Widget form;
-
- static Widget w_GN;
- static Widget w_PW;
- static Widget w_PB;
- static Widget w_WR;
- static Widget w_BR;
- static Widget w_WS;
- static Widget w_BS;
- static Widget w_EV;
- static Widget w_PC;
- static Widget w_DT;
- static Widget w_RO;
- static Widget w_HA;
- static Widget w_KM;
- static Widget w_TM;
- static Widget w_RE;
- static Widget w_US;
- static Widget w_SO;
- static Widget w_GC;
-
- /*******************************************************************************************************
- */
-
- static void SetEventProperty (w, id, node)
- Widget w;
- int id;
- SG_NodePtr node;
- {
- Arg arg;
- String text;
- SG_PropertyPtr property;
-
- XtSetArg (arg, XtNstring, &text); XtGetValues (w, &arg, 1);
-
- if (node != NULL) {
- property = SG_GetProperty (node, id);
-
- if (property != NULL && strcmp (property->data.pvalue, text) != 0) {
- SG_strcpy (&property->data.pvalue, text, '\0');
- modified = True;
- }
-
- else if (strcmp (text, "") != 0 && property == NULL) {
- SG_MakeProperty (node, id, text);
- modified = True;
- }
- }
- }
-
- /*******************************************************************************************************
- */
-
- static void infoCancel (w, event)
- Widget w;
- XEvent *event;
- {
- XtPopdown (i_top);
- }
-
- /*******************************************************************************************************
- */
-
- static void highlightText (w, event)
- Widget w;
- XEvent *event;
- {
- Arg args[1];
-
- if (edit == True) {
- XtSetArg (args[0], XtNdisplayCaret, True);
- XtSetValues (w, args, 1);
- }
- }
-
- /*******************************************************************************************************
- */
-
- static void unhighlightText (w, event)
- Widget w;
- XEvent *event;
- {
- Arg args[1];
-
- if (edit == True) {
- XtSetArg (args[0], XtNdisplayCaret, False);
- XtSetValues (w, args, 1);
- }
- }
-
- /*******************************************************************************************************
- */
-
- static void infoConfirm (w, event)
- Widget w;
- XEvent *event;
- {
- SG_NodePtr node = current_node;
-
- if (edit == True) {
- while (node->type != SG_EventType) {
- while (node->left != NULL)
- node = node->left;
- while (node->up != NULL)
- node = node->up;
- }
-
- SetEventProperty (w_PB, SG_PlayerBlack, node);
- SetEventProperty (w_PW, SG_PlayerWhite, node);
- SetEventProperty (w_BS, SG_BlackSpec , node);
- SetEventProperty (w_WS, SG_WhiteSpec , node);
- SetEventProperty (w_BR, SG_BlackRank , node);
- SetEventProperty (w_WR, SG_WhiteRank , node);
- SetEventProperty (w_EV, SG_EVent , node);
- SetEventProperty (w_RO, SG_ROund , node);
- SetEventProperty (w_PC, SG_PlaCe , node);
- SetEventProperty (w_DT, SG_DaTe , node);
- SetEventProperty (w_HA, SG_HAndicap , node);
- SetEventProperty (w_KM, SG_KoMi , node);
- SetEventProperty (w_TM, SG_TiMe , node);
- SetEventProperty (w_RE, SG_REsult , node);
- SetEventProperty (w_US, SG_USer , node);
- SetEventProperty (w_SO, SG_SOurce , node);
- SetEventProperty (w_GN, SG_GameName , node);
- SetEventProperty (w_GC, SG_GameComment, node);
- }
-
- XtPopdown (i_top);
- }
-
- void EventInfo (w, event)
- Widget w;
- XEvent *event;
- {
- SG_NodePtr node = current_node;
- SG_PropertyPtr property;
- Arg args[4];
- int xtargc;
- Widget text;
-
- while (node->type != SG_EventType) {
- while (node->left != NULL)
- node = node->left;
- while (node->up != NULL)
- node = node->up;
- }
-
- if (node->type == SG_EventType) {
- CenterWindow (i_top, NULL);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNstring, (XtArgVal) ""); xtargc++;
- XtSetArg (args[xtargc], XtNeditType,
- (XtArgVal) (edit == True) ? XawtextEdit : XawtextRead); xtargc++;
-
-
- XtSetValues (w_PB, args, xtargc);
- XtSetValues (w_PW, args, xtargc);
- XtSetValues (w_BS, args, xtargc);
- XtSetValues (w_WS, args, xtargc);
- XtSetValues (w_BR, args, xtargc);
- XtSetValues (w_WR, args, xtargc);
- XtSetValues (w_EV, args, xtargc);
- XtSetValues (w_RO, args, xtargc);
- XtSetValues (w_PC, args, xtargc);
- XtSetValues (w_DT, args, xtargc);
- XtSetValues (w_HA, args, xtargc);
- XtSetValues (w_KM, args, xtargc);
- XtSetValues (w_TM, args, xtargc);
- XtSetValues (w_RE, args, xtargc);
- XtSetValues (w_US, args, xtargc);
- XtSetValues (w_SO, args, xtargc);
- XtSetValues (w_GC, args, xtargc);
- XtSetValues (w_GN, args, xtargc);
-
- property = node->property;
-
- while (property != NULL) {
- switch (property->id) {
- case SG_PlayerBlack : text = w_PB; break;
- case SG_PlayerWhite : text = w_PW; break;
- case SG_BlackSpec : text = w_BS; break;
- case SG_WhiteSpec : text = w_WS; break;
- case SG_BlackRank : text = w_BR; break;
- case SG_WhiteRank : text = w_WR; break;
- case SG_EVent : text = w_EV; break;
- case SG_ROund : text = w_RO; break;
- case SG_PlaCe : text = w_PC; break;
- case SG_DaTe : text = w_DT; break;
- case SG_HAndicap : text = w_HA; break;
- case SG_KoMi : text = w_KM; break;
- case SG_TiMe : text = w_TM; break;
- case SG_REsult : text = w_RE; break;
- case SG_USer : text = w_US; break;
- case SG_SOurce : text = w_SO; break;
- case SG_GameName : text = w_GN; break;
- case SG_GameComment : text = w_GC; break;
- default : text = NULL;
- }
-
- if (text != NULL && property->data.pvalue != NULL)
- { XtSetArg (args[0], XtNstring, property->data.pvalue); XtSetValues (text, args, 1); }
-
- property = property->next;
- }
-
- XtPopup (i_top, XtGrabNonexclusive);
- }
- }
-
- /*******************************************************************************************************
- */
-
- static Widget make_label (form, name, label, horiz, vert, width, justify)
- Widget form;
- String name;
- String label;
- Widget horiz;
- Widget vert;
- Dimension width;
- XtArgVal justify;
- {
- Arg args[8];
- int xtargc;
-
- xtargc = 0;
- if (horiz != NULL) { XtSetArg (args[xtargc], XtNfromHoriz, horiz); xtargc++; }
- if (vert != NULL) { XtSetArg (args[xtargc], XtNfromVert , vert ); xtargc++; }
-
- XtSetArg (args[xtargc], XtNjustify , justify ); xtargc++;
- XtSetArg (args[xtargc], XtNlabel , label ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , width + 2); xtargc++;
- XtSetArg (args[xtargc], XtNborderWidth , 0 ); xtargc++;
- XtSetArg (args[xtargc], XtNinternalHeight, 3 ); xtargc++;
-
- return XtCreateManagedWidget (name, labelWidgetClass, form, args, xtargc);
- }
-
- /*******************************************************************************************************
- */
-
- static XtTranslations translations;
-
- static Widget make_text (form, name, horiz, vert, width)
- Widget form;
- String name;
- Widget horiz;
- Widget vert;
- Dimension width;
- {
- Arg args[8];
- int xtargc;
-
- xtargc = 0;
- if (horiz != NULL) { XtSetArg (args[xtargc], XtNfromHoriz, (XtArgVal) horiz); xtargc++; }
- if (vert != NULL) { XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) vert ); xtargc++; }
-
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) width ); xtargc++;
- XtSetArg (args[xtargc], XtNeditType , (XtArgVal) XawtextEdit ); xtargc++;
- XtSetArg (args[xtargc], XtNtranslations, (XtArgVal) translations); xtargc++;
- XtSetArg (args[xtargc], XtNdisplayCaret, (XtArgVal) False ); xtargc++;
-
- return XtCreateManagedWidget (name, asciiTextWidgetClass, form, args, xtargc);
- }
-
- /*******************************************************************************************************
- */
-
- void makeEventWindow (toplevel, app_context)
- Widget toplevel;
- XtAppContext app_context;
-
- {
- static XtActionsRec actions[] = {
- { "infoConfirm" , infoConfirm , },
- { "infoCancel" , infoCancel , },
- { "highlightText" , highlightText , },
- { "unhighlightText" , unhighlightText , },
- };
-
- Arg args[10];
- int xtargc;
-
- Widget game;
- Widget name, rank, species, white, black;
- Widget event, place, date, round;
- Widget handicap, komi, time, result;
- Widget user, source;
- Widget cancel, confirm;
-
- XtAppAddActions (app_context, actions, XtNumber(actions));
-
- translations = XtParseTranslationTable
- ("#override \
- <EnterWindow> : highlightText() \n\
- <LeaveWindow> : unhighlightText() \n\
- <Key> Escape : infoCancel() \n\
- <Key> Linefeed : infoConfirm() \n\
- <Key> Return : infoConfirm() \n\
- Ctrl <Key> J : infoConfirm() \n\
- Ctrl <Key> M : infoConfirm()");
-
- i_top = XtCreatePopupShell ("event" , transientShellWidgetClass, toplevel , NULL, 0);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNtranslations, (XtArgVal) translations); xtargc++;
-
- form = XtCreateManagedWidget ("eventForm" , formWidgetClass , i_top , args, xtargc);
-
-
- game = make_label (form, "game" , "Game" , NULL , NULL , (Dimension) 66 , XtJustifyLeft);
-
- w_GN = make_text (form, "GN" , game , NULL , (Dimension) 200);
-
- name = make_label (form, "name" , "Name" , game , game , (Dimension) 200, XtJustifyCenter);
- rank = make_label (form, "rank" , "Rank" , name , game , (Dimension) 80 , XtJustifyCenter);
- species = make_label (form, "species" , "Species" , rank , game , (Dimension) 80 , XtJustifyCenter);
-
- white = make_label (form, "white" , "White" , NULL , name , (Dimension) 66 , XtJustifyLeft);
- black = make_label (form, "black" , "Black" , NULL , white , (Dimension) 66 , XtJustifyLeft);
-
- w_PW = make_text (form, "PW" , white , name , 200);
- w_PB = make_text (form, "PB" , black , w_PW , 200);
- w_WR = make_text (form, "WR" , w_PW , rank , 80 );
- w_BR = make_text (form, "BR" , w_PB , w_WR , 80 );
- w_WS = make_text (form, "WS" , w_WR , species, 80 );
- w_BS = make_text (form, "BS" , w_BR , w_WS , 80 );
-
- event = make_label (form, "event" , "Event" , NULL , black , (Dimension) 66 , XtJustifyLeft);
- place = make_label (form, "place" , "Place" , NULL , event , (Dimension) 66 , XtJustifyLeft);
- date = make_label (form, "date" , "Date" , NULL , place , (Dimension) 66 , XtJustifyLeft);
- round = make_label (form, "round" , "Round" , NULL , date , (Dimension) 66 , XtJustifyLeft);
-
- w_EV = make_text (form, "EV" , event , black , (Dimension) 200);
- w_PC = make_text (form, "PC" , place , w_EV , (Dimension) 200);
- w_DT = make_text (form, "DT" , date , w_PC , (Dimension) 200);
- w_RO = make_text (form, "RO" , round , w_DT , (Dimension) 200);
-
- handicap = make_label (form, "handicap", "Handicap", w_EV , black , (Dimension) 66 , XtJustifyLeft);
- komi = make_label (form, "komi" , "Komi" , w_PC , handicap, (Dimension) 66 , XtJustifyLeft);
- time = make_label (form, "time" , "Time" , w_DT , komi , (Dimension) 66 , XtJustifyLeft);
- result = make_label (form, "result" , "Result" , w_RO , time , (Dimension) 66 , XtJustifyLeft);
-
- w_HA = make_text (form, "HA" , handicap , black , (Dimension) 80);
- w_KM = make_text (form, "KM" , komi , w_HA , (Dimension) 80);
- w_TM = make_text (form, "TM" , time , w_KM , (Dimension) 80);
- w_RE = make_text (form, "RE" , result , w_TM , (Dimension) 80);
-
- user = make_label (form, "user" , "User" , NULL , round , (Dimension) 66 , XtJustifyLeft);
- source = make_label (form, "komi" , "Source" , NULL , user , (Dimension) 66 , XtJustifyLeft);
-
- w_US = make_text (form, "US" , user , round , (Dimension) 200);
- w_SO = make_text (form, "SO" , source , w_US , (Dimension) 200);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNlabel , (XtArgVal) CancelLabel ); xtargc++;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) round ); xtargc++;
- XtSetArg (args[xtargc], XtNfromHoriz , (XtArgVal) w_US ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 100 ); xtargc++;
-
- #ifndef NO_EXTENSION
- XtSetArg (args[xtargc], XtNshapeStyle , (XtArgVal) XmuShapeOval); xtargc++;
- #endif
-
- cancel = XtCreateManagedWidget ("cancel" , commandWidgetClass , form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNlabel , (XtArgVal) ConfirmLabel); xtargc++;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) cancel ); xtargc++;
- XtSetArg (args[xtargc], XtNfromHoriz , (XtArgVal) w_US ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 100 ); xtargc++;
-
- #ifndef NO_EXTENSION
- XtSetArg (args[xtargc], XtNshapeStyle , (XtArgVal) XmuShapeOval); xtargc++;
- #endif
-
- confirm = XtCreateManagedWidget ("confirm" , commandWidgetClass , form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) translations); xtargc++;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) source ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 444 ); xtargc++;
- XtSetArg (args[xtargc], XtNheight , (XtArgVal) 150 ); xtargc++;
- XtSetArg (args[xtargc], XtNscrollVertical , (XtArgVal) XawtextScrollAlways); xtargc++;
- XtSetArg (args[xtargc], XtNeditType , (XtArgVal) XawtextEdit ); xtargc++;
- XtSetArg (args[xtargc], XtNdisplayCaret , (XtArgVal) False ); xtargc++;
-
- w_GC = XtCreateManagedWidget ("GC" , asciiTextWidgetClass , form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNvertDistance , (XtArgVal) 16); xtargc++;
-
- XtSetValues (event , args, xtargc);
- XtSetValues (w_EV , args, xtargc);
- XtSetValues (w_HA , args, xtargc);
- XtSetValues (user , args, xtargc);
- XtSetValues (w_US , args, xtargc);
- XtSetValues (cancel , args, xtargc);
- XtSetValues (w_GC , args, xtargc);
- XtSetValues (handicap , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNvertDistance , (XtArgVal) 8 ); xtargc++;
-
- XtSetValues (w_GN , args, xtargc);
- XtSetValues (game , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNhorizDistance, (XtArgVal) 18); xtargc++;
-
- XtSetValues (handicap , args, xtargc);
- XtSetValues (komi , args, xtargc);
- XtSetValues (time , args, xtargc);
- XtSetValues (result , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNhorizDistance, (XtArgVal) 37); xtargc++;
-
- XtSetValues (confirm , args, xtargc);
- XtSetValues (cancel , args, xtargc);
-
- XtAddCallback (confirm, XtNcallback, infoConfirm, NULL);
- XtAddCallback (cancel , XtNcallback, infoCancel , NULL);
- }
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'dialog.c'
- then
- echo shar: will not over-write existing file "'dialog.c'"
- else
- cat << \SHAR_EOF > 'dialog.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include <stdio.h>
- #include <ctype.h>
-
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/StringDefs.h>
-
- #include <X11/Xaw/Command.h>
- #include <X11/Xaw/Form.h>
- #include <X11/Xaw/Label.h>
- #include <X11/Xaw/AsciiText.h>
-
- #include "xgoban.h"
-
- /*******************************************************************************************************
- */
-
- static Widget d_top;
- static Widget d_form;
- static Widget d_msg;
- static Widget d_text;
- static Widget d_confirm;
- static Widget d_cancel;
-
- static Widget a_top;
- static Widget a_form;
- static Widget a_msg;
- static Widget a_confirm;
- static Widget a_cancel;
-
- static Widget w_top;
- static Widget w_form;
- static Widget w_msg;
- static Widget w_confirm;
-
- static Widget h_top;
- static Widget h_text;
-
- static int dialog_mode = -1;
- static Widget dialog_widget;
-
- static XEvent delay_event;
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void PopupDialog (w, event, mode)
- Widget w;
- XEvent *event;
- int mode;
- {
- SG_PropertyPtr property;
- Widget top;
- Widget focus;
- Arg arg;
-
- switch (mode) {
-
- case HelpDialog :
- top = h_top;
- focus = NULL;
- break;
-
- case ReallyQuitDialog :
- XtSetArg (arg, XtNlabel, (XtArgVal) ReallyQuitMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) QuitLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel ); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case ReallyDeleteDialog :
-
- delay_event = *event;
-
- XtSetArg (arg, XtNlabel, (XtArgVal) ReallyDeleteMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) DeleteLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel ); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case SaveBeforeQuitDialog :
- case SaveBeforeLoadDialog :
- XtSetArg (arg, XtNlabel, (XtArgVal) SaveFileBeforeMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) YesLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) NoLabel ); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case SaveAsAndLoadDialog :
- case SaveAsAndQuitDialog :
- case SaveAsDialog :
- XtSetArg (arg, XtNstring , (XtArgVal) file_name ); XtSetValues (d_text , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) SaveFileMsg ); XtSetValues (d_msg , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) SaveLabel ); XtSetValues (d_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) CancelLabel ); XtSetValues (d_cancel , &arg, 1);
-
- top = d_top;
- focus = d_text;
- break;
-
- case NodeNameDialog :
- property = SG_GetProperty (current_node, SG_nodeName);
-
- if (property != NULL && property->data.pvalue != NULL)
- { XtSetArg (arg, XtNstring , (XtArgVal) property->data.pvalue); XtSetValues (d_text , &arg, 1); }
- else
- { XtSetArg (arg, XtNstring , (XtArgVal) "" ); XtSetValues (d_text , &arg, 1); }
-
- XtSetArg (arg, XtNlabel , (XtArgVal) NodeNameMsg ); XtSetValues (d_msg , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) OkLabel ); XtSetValues (d_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) CancelLabel ); XtSetValues (d_cancel , &arg, 1);
-
- top = d_top;
- focus = d_text;
- break;
-
- case LoadDialog :
- XtSetArg (arg, XtNstring , (XtArgVal) "" ); XtSetValues (d_text , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) LoadFileMsg ); XtSetValues (d_msg , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) LoadLabel ); XtSetValues (d_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel , (XtArgVal) CancelLabel ); XtSetValues (d_cancel , &arg, 1);
-
- top = d_top;
- focus = d_text;
- break;
-
- case EditDialog :
- if (edit == True) return;
-
- delay_event = *event;
-
- XtSetArg (arg, XtNlabel, (XtArgVal) EditFileMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) EditLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case StopGameDialog :
- delay_event = *event;
-
- case StopGameBeforeQuitDialog :
-
- XtSetArg (arg, XtNlabel, (XtArgVal) StopGameMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) StopLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case ReplaceNodeDialog :
- delay_event = *event;
-
- XtSetArg (arg, XtNlabel, (XtArgVal) ReplaceNodeMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) ReplaceLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel ); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case MailConfirmMoveDialog :
- delay_event = *event;
-
- XtSetArg (arg, XtNlabel, (XtArgVal) MailConfirmMoveMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) ConfirmLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel ); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case MailNoMoveDialog :
- delay_event = *event;
-
- XtSetArg (arg, XtNlabel, (XtArgVal) MailNoMoveMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) QuitLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel ); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- case RemoveStonesDialog :
- delay_event = *event;
-
- XtSetArg (arg, XtNlabel, (XtArgVal) RemoveStonesMsg); XtSetValues (a_msg , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) RemoveLabel ); XtSetValues (a_confirm , &arg, 1);
- XtSetArg (arg, XtNlabel, (XtArgVal) CancelLabel ); XtSetValues (a_cancel , &arg, 1);
-
- top = a_top;
- focus = a_confirm;
- break;
-
- default :
- switch (mode) {
- case PlayerNodeErrorWarning : XtSetArg (arg, XtNlabel, PlayerNodeErrorMsg ); XtSetValues (w_msg, &arg, 1); break;
- case PlayerMoveErrorWarning : XtSetArg (arg, XtNlabel, PlayerMoveErrorMsg ); XtSetValues (w_msg, &arg, 1); break;
- case MemoryErrorDialog : XtSetArg (arg, XtNlabel, MemoryErrorMsg ); XtSetValues (w_msg, &arg, 1); break;
- case CantOpenFileDialog : XtSetArg (arg, XtNlabel, CantOpenFileMsg ); XtSetValues (w_msg, &arg, 1); break;
- case IllegalMoveDialog : XtSetArg (arg, XtNlabel, IllegalMoveMsg ); XtSetValues (w_msg, &arg, 1); break;
- case SuicideMoveDialog : XtSetArg (arg, XtNlabel, SuicideMoveMsg ); XtSetValues (w_msg, &arg, 1); break;
- case KoMoveDialog : XtSetArg (arg, XtNlabel, KoMoveMsg ); XtSetValues (w_msg, &arg, 1); break;
- case BadHandicapWarning : XtSetArg (arg, XtNlabel, BadHandicapMsg ); XtSetValues (w_msg, &arg, 1); break;
- case RemainingStonesWarning : XtSetArg (arg, XtNlabel, RemainingStonesMsg ); XtSetValues (w_msg, &arg, 1); break;
- case DiagramBadNodeWarning : XtSetArg (arg, XtNlabel, DiagramBadNodeMsg ); XtSetValues (w_msg, &arg, 1); break;
- case SizeBadNodeWarning : XtSetArg (arg, XtNlabel, SizeBadNodeMsg ); XtSetValues (w_msg, &arg, 1); break;
- case WallyWhitePlayWarning : XtSetArg (arg, XtNlabel, WallyWhitePlayMsg ); XtSetValues (w_msg, &arg, 1); break;
- case WallyBadSizeWarning : XtSetArg (arg, XtNlabel, WallyBadSizeMsg ); XtSetValues (w_msg, &arg, 1); break;
- case WallyBadHandicapWarning : XtSetArg (arg, XtNlabel, WallyBadHandicapMsg); XtSetValues (w_msg, &arg, 1); break;
- case BlackPassDialog : XtSetArg (arg, XtNlabel, BlackPassMsg ); XtSetValues (w_msg, &arg, 1); break;
- case WhitePassDialog : XtSetArg (arg, XtNlabel, WhitePassMsg ); XtSetValues (w_msg, &arg, 1); break;
- }
-
- top = w_top;
- focus = w_confirm;
- break;
- }
-
- dialog_mode = mode;
- dialog_widget = top;
-
- CenterWindow (top, focus);
- XtPopup (top, XtGrabNonexclusive);
- }
-
- /*******************************************************************************************************
- */
-
- static void dialogConfirm (w, event)
- Widget w;
- XEvent *event;
- {
- SG_NodePtr node;
- String name;
- Arg arg;
-
- XtPopdown (dialog_widget);
-
- switch (dialog_mode) {
-
- case ReallyDeleteDialog :
- delete_confirm = True;
- XPutBackEvent (XtDisplay (w), &delay_event);
- break;
-
- case ReallyQuitDialog :
- exit (1);
- break;
-
- case SaveBeforeQuitDialog :
- if (file_name[0] != '\0') {
- if (SaveFile (w, event, file_name) == True)
- (void) exit (1);
- }
-
- else
- PopupDialog (w, event, SaveAsAndQuitDialog);
- break;
-
- case SaveBeforeLoadDialog :
- if (file_name[0] != '\0') {
- if (SaveFile (w, event, file_name) == True)
- PopupDialog (w, event, LoadDialog);
- }
-
- else
- PopupDialog (w, event, SaveAsAndLoadDialog);
- break;
-
- case NodeNameDialog :
- XtSetArg (arg, XtNstring, (XtArgVal) &name);
- XtGetValues (d_text, &arg, 1);
-
- SG_MakeProperty (current_node, SG_nodeName, name);
- ShowTmpProperty (current_node);
-
- modified = True;
- break;
-
- case SaveAsAndQuitDialog :
- case SaveAsAndLoadDialog :
- case SaveAsDialog :
-
- XtSetArg (arg, XtNstring, (XtArgVal) &name); XtGetValues (d_text, &arg, 1);
-
- if (SaveFile (w, event, name) == True)
- switch (dialog_mode) {
- case SaveAsAndQuitDialog : exit (1);
- case SaveAsAndLoadDialog : PopupDialog (w, event, LoadDialog);
- }
- break;
-
- case LoadDialog :
- XtSetArg (arg, XtNstring , (XtArgVal) &name); XtGetValues (d_text, &arg, 1);
-
- if (LoadFile (w, event, name) == True) {
- XtSetArg (arg, XtNtitle , (XtArgVal) ApplicationName); XtSetValues (w_toplevel, &arg, 1);
- XtSetArg (arg, XtNstring, (XtArgVal) "" ); XtSetValues (c_comment , &arg, 1);
- XtSetArg (arg, XtNstring, (XtArgVal) "" ); XtSetValues (d_text , &arg, 1);
-
- GbClearBoard (w_goban);
-
- Play (current_node);
- ShowProperty (current_node);
- RedisplayBoard ();
-
- Edit (False);
- }
- break;
-
- case EditDialog :
- Edit (True);
-
- XPutBackEvent (XtDisplay (w), &delay_event);
- break;
-
- case StopGameDialog :
- stopGame ();
-
- XPutBackEvent (XtDisplay (w), &delay_event);
- break;
-
- case StopGameBeforeQuitDialog :
- stopGame ();
- (void) exit (1);
-
- /* NOTREACHED */
-
- case RemoveStonesDialog :
- case ReplaceNodeDialog :
- node = current_node->down;
-
- SG_RemoveNode (node);
- SG_FreeNode (node);
-
- modified = True;
-
- XPutBackEvent (XtDisplay (w), &delay_event);
- break;
-
- case MailNoMoveDialog :
- (void) exit (1);
-
- /* NOTREACHED */
-
- case MailConfirmMoveDialog :
- if (SaveFile (w, event, mail_file_name) == True)
- (void) exit (0);
- else
- (void) exit (1);
-
- /* NOTREACHED */
- }
- }
-
- /*******************************************************************************************************
- */
-
- static void dialogCancel (w, event)
- Widget w;
- XEvent *event;
- {
- XtPopdown (dialog_widget);
-
- switch (dialog_mode) {
- case SaveBeforeQuitDialog : PopupDialog (w, event, ReallyQuitDialog); break;
- case SaveBeforeLoadDialog : PopupDialog (w, event, LoadDialog ); break;
- }
- }
-
- /*******************************************************************************************************
- */
-
- void makeDialogWindow (toplevel, app_context)
- Widget toplevel;
- XtAppContext app_context;
- {
- static XtActionsRec actions[] = {
- { "dialogConfirm" , dialogConfirm , },
- { "dialogCancel" , dialogCancel , },
- };
-
- Arg args[10];
- int xtargc;
- XtTranslations translations;
-
- XtAppAddActions (app_context, actions, XtNumber(actions));
-
- /*
- * Dialog Window.
- */
-
- translations = XtParseTranslationTable
- ("#override \
- <Key> Escape : dialogCancel() \n\
- <Key> Linefeed : dialogConfirm() \n\
- <Key> Return : dialogConfirm() \n\
- Ctrl <Key> J : dialogConfirm() \n\
- Ctrl <Key> M : dialogConfirm()");
-
- d_top = XtCreatePopupShell ("dialog" , transientShellWidgetClass, toplevel , NULL, 0);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNdefaultDistance , (XtArgVal) 12 ); xtargc++;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) translations); xtargc++;
-
- d_form = XtCreateManagedWidget ("form" , formWidgetClass , d_top , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 294 ); xtargc++;
- XtSetArg (args[xtargc], XtNborderWidth , (XtArgVal) 0 ); xtargc++;
-
- d_msg = XtCreateManagedWidget ("msg" , labelWidgetClass , d_form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) d_msg ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 294 ); xtargc++;
- XtSetArg (args[xtargc], XtNvertDistance , (XtArgVal) 8 ); xtargc++;
- XtSetArg (args[xtargc], XtNeditType , (XtArgVal) XawtextEdit ); xtargc++;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) translations); xtargc++;
-
- d_text = XtCreateManagedWidget ("text" , asciiTextWidgetClass, d_form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) d_text ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 140 ); xtargc++;
-
- #ifndef NO_EXTENSION
- XtSetArg (args[xtargc], XtNshapeStyle , (XtArgVal) XmuShapeOval); xtargc++;
- #endif
-
- d_cancel = XtCreateManagedWidget ("cancel" , commandWidgetClass , d_form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) d_text ); xtargc++;
- XtSetArg (args[xtargc], XtNfromHoriz , (XtArgVal) d_cancel ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 140 ); xtargc++;
-
- #ifndef NO_EXTENSION
- XtSetArg (args[xtargc], XtNshapeStyle , (XtArgVal) XmuShapeOval); xtargc++;
- #endif
-
- d_confirm = XtCreateManagedWidget ("confirm" , commandWidgetClass , d_form , args, xtargc);
-
- XtAddCallback (d_cancel , XtNcallback, dialogCancel , NULL);
- XtAddCallback (d_confirm, XtNcallback, dialogConfirm, NULL);
-
- XtRealizeWidget (d_top);
-
- /*
- * Ask Window.
- */
-
- a_top = XtCreatePopupShell ("ask", transientShellWidgetClass, toplevel, NULL, 0);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNdefaultDistance, (XtArgVal) 12 ); xtargc++;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) translations); xtargc++;
-
- a_form = XtCreateManagedWidget ("form" , formWidgetClass , a_top , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 214 ); xtargc++;
- XtSetArg (args[xtargc], XtNheight , (XtArgVal) 30 ); xtargc++;
- XtSetArg (args[xtargc], XtNborderWidth , (XtArgVal) 0 ); xtargc++;
-
- a_msg = XtCreateManagedWidget ("msg" , labelWidgetClass , a_form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) a_msg ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 100 ); xtargc++;
-
- #ifndef NO_EXTENSION
- XtSetArg (args[xtargc], XtNshapeStyle , (XtArgVal) XmuShapeOval); xtargc++;
- #endif
-
- a_cancel = XtCreateManagedWidget ("cancel" , commandWidgetClass , a_form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) a_msg ); xtargc++;
- XtSetArg (args[xtargc], XtNfromHoriz , (XtArgVal) a_cancel ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 100 ); xtargc++;
-
- #ifndef NO_EXTENSION
- XtSetArg (args[xtargc], XtNshapeStyle , (XtArgVal) XmuShapeOval); xtargc++;
- #endif
-
- a_confirm = XtCreateManagedWidget ("confirm" , commandWidgetClass , a_form , args, xtargc);
-
- XtAddCallback (a_cancel , XtNcallback, dialogCancel , NULL);
- XtAddCallback (a_confirm, XtNcallback, dialogConfirm, NULL);
-
- XtRealizeWidget (a_top);
-
- /*
- * Warning Window.
- */
-
- translations = XtParseTranslationTable
- ("#override \
- <BtnDown> : dialogCancel() \n\
- <Key> : dialogCancel()");
-
- w_top = XtCreatePopupShell ("warning", transientShellWidgetClass, toplevel, NULL, 0);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNdefaultDistance, (XtArgVal) 12 ); xtargc++;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) translations); xtargc++;
-
- w_form = XtCreateManagedWidget ("form" , formWidgetClass , w_top , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 206 ); xtargc++;
- XtSetArg (args[xtargc], XtNheight , (XtArgVal) 48 ); xtargc++;
- XtSetArg (args[xtargc], XtNborderWidth , (XtArgVal) 0 ); xtargc++;
-
- w_msg = XtCreateManagedWidget ("msg" , labelWidgetClass , w_form , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNfromVert , (XtArgVal) w_msg ); xtargc++;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 100 ); xtargc++;
- XtSetArg (args[xtargc], XtNhorizDistance , (XtArgVal) 65 ); xtargc++;
- XtSetArg (args[xtargc], XtNlabel , (XtArgVal) OkLabel ); xtargc++;
-
- #ifndef NO_EXTENSION
- XtSetArg (args[xtargc], XtNshapeStyle , (XtArgVal) XmuShapeOval); xtargc++;
- #endif
-
- w_confirm = XtCreateManagedWidget ("confirm" , commandWidgetClass , w_form , args, xtargc);
-
- XtAddCallback (w_confirm, XtNcallback, dialogCancel, NULL);
-
- XtRealizeWidget (w_top);
-
- /*
- * Help window
- */
-
- h_top = XtCreatePopupShell ("help", transientShellWidgetClass, w_toplevel, NULL, 0);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNlabel , (XtArgVal) HelpString ); xtargc++;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) translations); xtargc++;
-
- h_text = XtCreateManagedWidget ("text" , labelWidgetClass , h_top , args, xtargc);
-
- XtRealizeWidget (h_top);
- }
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'xgoban.c'
- then
- echo shar: will not over-write existing file "'xgoban.c'"
- else
- cat << \SHAR_EOF > 'xgoban.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include <stdio.h>
- #include <malloc.h>
- #include <ctype.h>
-
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/StringDefs.h>
-
- #include <X11/Xaw/Form.h>
- #include <X11/Xaw/AsciiText.h>
- #include <X11/Xaw/SimpleMenu.h>
- #include <X11/Xaw/SmeBSB.h>
-
- #include "xgoban.h"
- #include "icon.bm"
-
- Widget w_toplevel;
- Widget w_form;
- Widget w_goban;
- Widget w_menu = NULL;
- Widget c_toplevel;
- Widget c_comment;
- Widget w_second_toplevel = NULL;
- Widget w_second_goban = NULL;
-
- SG_NodePtr tree = NULL;
- SG_NodePtr current_node = NULL;
- SG_NodePtr mail_node = NULL;
-
- Mode current_mode = EditMode;
-
- Player black_player = Human;
- Player white_player = Human;
- int handicap = 0;
- int board_size = 19;
- int second_player = 0;
-
- Boolean edit = False;
- Boolean modified = False;
- Boolean autonum;
- Boolean strict;
- Boolean short_print = False;
- int beep;
-
- String file = NULL;
-
- char file_name[512];
- char mail_file_name[512];
- char *path;
-
- /*******************************************************************************************************
- */
-
- typedef struct {
- int handicap;
- int size;
- int stipple;
- String path;
- String mail;
- int beep;
- Boolean help;
- Boolean autonum;
- Boolean strict;
- Boolean short_print;
- String black;
- String white;
- Dimension point_size;
- String white_dsp;
- String black_dsp;
- } AppData, *AppDataPtr;
-
- static XtResource resources[] = {
- { "blackDisplay", XtCString , XtRString , sizeof (String) , XtOffset (AppDataPtr, black_dsp) , XtRString , (caddr_t) NULL , },
- { "whiteDisplay", XtCString , XtRString , sizeof (String) , XtOffset (AppDataPtr, white_dsp) , XtRString , (caddr_t) NULL , },
- { "path" , XtCString , XtRString , sizeof (String) , XtOffset (AppDataPtr, path) , XtRString , (caddr_t) "." , },
- { "handicap" , "Handicap" , XtRInt , sizeof (int) , XtOffset (AppDataPtr, handicap) , XtRImmediate , (caddr_t) 0 , },
- { "size" , "Size" , XtRInt , sizeof (int) , XtOffset (AppDataPtr, size) , XtRImmediate , (caddr_t) 19 , },
- { "stipple" , "Stipple" , XtRInt , sizeof (int) , XtOffset (AppDataPtr, stipple) , XtRImmediate , (caddr_t) 0 , },
- { "beep" , "Beep" , XtRInt , sizeof (int) , XtOffset (AppDataPtr, beep) , XtRImmediate , (caddr_t) 0 , },
- { "short" , XtCBoolean , XtRBoolean , sizeof (Boolean) , XtOffset (AppDataPtr, short_print), XtRImmediate , (caddr_t) False, },
- { "mail" , XtCString , XtRString , sizeof (String) , XtOffset (AppDataPtr, mail) , XtRString , (caddr_t) NULL , },
- { "autonum" , XtCBoolean , XtRBoolean , sizeof (Boolean) , XtOffset (AppDataPtr, autonum) , XtRImmediate , (caddr_t) True , },
- { "versatile" , XtCBoolean , XtRBoolean , sizeof (Boolean) , XtOffset (AppDataPtr, strict) , XtRImmediate , (caddr_t) True , },
- { "black" , XtCString , XtRString , sizeof (String) , XtOffset (AppDataPtr, black) , XtRImmediate , (caddr_t) NULL , },
- { "white" , XtCString , XtRString , sizeof (String) , XtOffset (AppDataPtr, white) , XtRImmediate , (caddr_t) NULL , },
- { "help" , XtCBoolean , XtRBoolean , sizeof (Boolean) , XtOffset (AppDataPtr, help) , XtRImmediate , (caddr_t) False, },
- { "pointSize" , "Size" , XtRDimension, sizeof (Dimension), XtOffset (AppDataPtr, point_size) , XtRImmediate , (caddr_t) 26 , },
- };
-
- static XrmOptionDescRec options[] = {
- { "-help" , ".help" , XrmoptionNoArg , "True" , },
- { "-size" , ".size" , XrmoptionSepArg , NULL , },
- { "-handicap" , ".handicap" , XrmoptionSepArg , NULL , },
- { "-path" , ".path" , XrmoptionSepArg , NULL , },
- { "-pointSize" , ".pointSize" , XrmoptionSepArg , NULL , },
- { "-silent" , ".beep" , XrmoptionNoArg , "-101" , },
- { "-beep" , ".beep" , XrmoptionSepArg , NULL , },
- { "-nonum" , ".autonum" , XrmoptionNoArg , "False" , },
- { "-versatile" , ".versatile" , XrmoptionNoArg , "False" , },
- { "-black" , ".black" , XrmoptionSepArg , NULL , },
- { "-white" , ".white" , XrmoptionSepArg , NULL , },
- { "-stipple1" , ".stipple" , XrmoptionNoArg , "1" , },
- { "-stipple2" , ".stipple" , XrmoptionNoArg , "2" , },
- { "-stipple3" , ".stipple" , XrmoptionNoArg , "3" , },
-
-
- { "-m" , ".mail" , XrmoptionSepArg , NULL , },
- { "-s" , ".short" , XrmoptionNoArg , "True" , },
- { "-mail" , ".mail" , XrmoptionSepArg , NULL , },
- { "-short" , ".short" , XrmoptionNoArg , "True" , },
- { "-blackDisplay" , ".blackDisplay" , XrmoptionSepArg , NULL , },
- { "-whiteDisplay" , ".whiteDisplay" , XrmoptionSepArg , NULL , },
- };
-
- static AppData app_data;
-
- static char *stars[18] = {
- "", /* 2 */
- "", /* 3 */
- "", /* 4 */
- "", /* 5 */
- "", /* 6 */
- "", /* 7 */
- "cffcffcc", /* 8 */
- "cggcggccee", /* 9 */
- "hchhchcc", /* 10 */
- "ciiciiccffcfiffcfi", /* 11 */
- "cjjcjjcc", /* 12 */
- "ckkckkccggcgkggcgk", /* 13 */
- "dkkdkkdd", /* 14 */
- "dlldllddhhdhlhhdhl", /* 15 */
- "dmmdmmdd", /* 16 */
- "dnndnnddiidiniidin", /* 17 */
- "doodoodd", /* 18 */
- "dppdppddjjdjpjjdjp", /* 19 */
- };
-
- char translations_table[] =
- "#override \
- Ctrl Shift <Key> P : makeVariationPass() \n\
- Shift <Key> A : selectVariation(A) \n\
- Shift <Key> B : selectVariation(B) \n\
- Shift <Key> C : selectVariation(C) \n\
- Shift <Key> D : selectVariation(D) \n\
- Shift <Key> E : selectVariation(E) \n\
- Shift <Key> F : selectVariation(F) \n\
- Shift <Key> G : selectVariation(G) \n\
- Shift <Key> H : selectVariation(H) \n\
- Shift <Key> I : selectVariation(I) \n\
- Shift <Key> J : selectVariation(J) \n\
- Shift <Key> K : selectVariation(K) \n\
- Shift <Key> L : selectVariation(L) \n\
- Shift <Key> M : selectVariation(M) \n\
- Shift <Key> N : selectVariation(N) \n\
- Shift <Key> O : selectVariation(O) \n\
- Shift <Key> P : selectVariation(P) \n\
- Shift <Key> Q : selectVariation(Q) \n\
- Shift <Key> R : selectVariation(R) \n\
- Shift <Key> S : selectVariation(S) \n\
- Shift <Key> T : selectVariation(T) \n\
- Shift <Key> U : selectVariation(U) \n\
- Shift <Key> V : selectVariation(V) \n\
- Shift <Key> W : selectVariation(W) \n\
- Shift <Key> X : selectVariation(X) \n\
- Shift <Key> Y : selectVariation(Y) \n\
- Shift <Key> Z : selectVariation(Z) \n\
- Shift <Key> } : nextComment() \n\
- Shift <Key> { : previousComment() \n\
- <Key> a : setMode(Diagram) \n\
- <Key> b : setPlayer(Black) \n\
- <Key> e : dialog(Edit) \n\
- <Key> p : pass() \n\
- <Key> i : eventInfo() \n\
- <Key> v : setMode(View) \n\
- <Key> w : setPlayer(White) \n\
- <Key> z : setMode(Size) \n\
- <Key> Escape : setMode(Edit) \n\
- <Key> l : dialog(Load) \n\
- <Key> n : dialog(NodeName) \n\
- <Key> q : exit() \n\
- <Key> s : dialog(Save) \n\
- <Key> ] : nextVariationBranch() \n\
- <Key> [ : previousVariationBranch() \n\
- <Key> < : previousMove() \n\
- <Key> > : nextMove() \n\
- <Key> ? : dialog(Help) \n\
- <Key> h : dialog(Help) \n\
- Ctrl Shift <Btn1Down> : makeVariation() \n\
- Ctrl Shift <Btn2Down> : makeVariationDiagram() \n\
- Shift <Btn1Down> : makeMove() \n\
- Shift <Btn3Down> : deleteMove() \n\
- Ctrl <Btn1Down> : letter() \n\
- Ctrl <Btn2Down> : mark() \n\
- Ctrl <Btn3Down> : deleteMark() \n\
- <Btn1Down> : nextMove() add(Black) drag(Start) \n\
- <Btn2Down> : add(White) selectDiagram() \n\
- <Btn3Down> : previousMove() add(Empty) \n\
- <Btn1Motion> : drag() \n\
- <Btn1Up> : drag(Stop) \n\
- ";
-
- /*******************************************************************************************************
- */
-
- extern void SelectDiagram ();
- extern void Dialog ();
- extern void NextMove ();
- extern void PreviousMove ();
- extern void SelectVariation ();
- extern void NextVariationBranch ();
- extern void PreviousVariationBranch ();
- extern void NextComment ();
- extern void PreviousComment ();
- extern void Exit ();
- extern void Help ();
- extern void PopdownHelp ();
- extern void MakeVariationDiagram ();
- extern void SetPlayer ();
- extern void Add ();
- extern void SetMode ();
- extern void MakeMove ();
- extern void Pass ();
- extern void DeleteMove ();
- extern void DeleteMark ();
- extern void MakeVariation ();
- extern void MakeVariationPass ();
- extern void Drag ();
- extern void Letter ();
- extern void Mark ();
- extern void EventInfo ();
-
- XtActionsRec actions[] = {
- { "selectDiagram" , SelectDiagram , },
- { "dialog" , Dialog , },
- { "nextMove" , NextMove , },
- { "previousMove" , PreviousMove , },
- { "selectVariation" , SelectVariation , },
- { "nextVariationBranch" , NextVariationBranch , },
- { "previousVariationBranch" , PreviousVariationBranch , },
- { "nextComment" , NextComment , },
- { "previousComment" , PreviousComment , },
- { "exit" , Exit , },
- { "makeVariationDiagram" , MakeVariationDiagram , },
- { "setPlayer" , SetPlayer , },
- { "add" , Add , },
- { "selectDiagram" , SelectDiagram , },
- { "setMode" , SetMode , },
- { "makeMove" , MakeMove , },
- { "deleteMove" , DeleteMove , },
- { "deleteMark" , DeleteMark , },
- { "pass" , Pass , },
- { "makeVariation" , MakeVariation , },
- { "makeVariationPass" , MakeVariationPass , },
- { "drag" , Drag , },
- { "letter" , Letter , },
- { "mark" , Mark , },
- { "eventInfo" , EventInfo , },
- };
-
- extern void exit ();
-
- #define stipple1_width 2
- #define stipple1_height 2
-
- static char stipple1_bits[] = {
- 0x01, 0x02};
-
- #define stipple2_width 4
- #define stipple2_height 4
-
- static char stipple2_bits[] = {
- 0x05, 0x00, 0x0a, 0x00};
-
- #define stipple3_width 4
- #define stipple3_height 4
-
- static char stipple3_bits[] = {
- 0x01, 0x00, 0x00, 0x00};
-
-
- void main (argc, argv)
- int argc;
- char **argv;
- {
- XtAppContext app_context;
- Display *display;
- Display *second_display;
- Drawable window;
- String title;
- String icon_title;
- Pixmap icon_pixmap;
- Arg args[16];
- int xtargc;
-
- w_toplevel = XtAppInitialize (&app_context, ApplicationName, options, XtNumber (options),
- &argc, argv, NULL, NULL, 0);
-
- XtGetApplicationResources (w_toplevel, &app_data, resources, XtNumber (resources), NULL, 0);
-
- if (argc == 2 && argv[1][0] != '-')
- file = argv[1];
-
- else if (argc > 1)
- app_data.help = True;
-
- /*
- * help option
- */
-
- if (app_data.help == True) {
- (void) fprintf (stderr, "%s", UsageString);
- (void) exit (1);
- }
-
- /*
- * Various options
- */
-
- if (app_data.beep > 100)
- app_data.beep = 0;
-
- path = app_data.path;
- beep = app_data.beep;
- autonum = app_data.autonum;
- strict = app_data.strict;
- short_print = app_data.short_print;
-
- if (strict == False) autonum = False;
-
- /*
- * Mail option
- */
-
- if (app_data.mail != NULL) {
-
- if (file == NULL) {
- (void) fprintf (stderr, "XGoban : Mail mode : no input file specified\n");
- (void) exit (1);
- }
-
- strcpy (mail_file_name, app_data.mail);
-
- current_mode = MailMode;
- edit = True;
- }
-
- /*
- * Widget creation
- */
-
- display = XtDisplay (w_toplevel);
- window = RootWindowOfScreen (XtScreen (w_toplevel));
-
- icon_pixmap = XCreateBitmapFromData (display, window, icon_bits, icon_width, icon_height);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNiconPixmap , (XtArgVal) icon_pixmap ); xtargc++;
- XtSetArg (args[xtargc], XtNtitle , (XtArgVal) ApplicationName ); xtargc++;
- XtSetArg (args[xtargc], XtNiconName , (XtArgVal) "Goban" ); xtargc++;
-
- XtSetValues (w_toplevel, args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) XtParseTranslationTable (translations_table)); xtargc++;
- XtSetArg (args[xtargc], XtNpointSize , (XtArgVal) app_data.point_size ); xtargc++;
- XtSetArg (args[xtargc], XtNautoRedisplay , (XtArgVal) False ); xtargc++;
-
- switch (app_data.stipple) {
- case 1 :
- XtSetArg (args[xtargc], XtNbackgroundPixmap ,
- XCreatePixmapFromBitmapData (display, window, (char *) stipple1_bits,
- stipple1_width, stipple1_height,
- BlackPixel (display, DefaultScreen (display)),
- WhitePixel (display, DefaultScreen (display)),
- DefaultDepthOfScreen (XtScreen (w_toplevel))));
- xtargc++;
- break;
- case 2 :
- XtSetArg (args[xtargc], XtNbackgroundPixmap ,
- XCreatePixmapFromBitmapData (display, window, (char *) stipple2_bits,
- stipple2_width, stipple2_height,
- BlackPixel (display, DefaultScreen (display)),
- WhitePixel (display, DefaultScreen (display)),
- DefaultDepthOfScreen (XtScreen (w_toplevel))));
- xtargc++;
- break;
- case 3 :
- XtSetArg (args[xtargc], XtNbackgroundPixmap ,
- XCreatePixmapFromBitmapData (display, window, (char *) stipple3_bits,
- stipple3_width, stipple3_height,
- BlackPixel (display, DefaultScreen (display)),
- WhitePixel (display, DefaultScreen (display)),
- DefaultDepthOfScreen (XtScreen (w_toplevel))));
- xtargc++;
- break;
- }
-
- w_goban = XtCreateManagedWidget ("goban" , gobanWidgetClass , w_toplevel , args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNiconPixmap , (XtArgVal) icon_pixmap ); xtargc++;
- XtSetArg (args[xtargc], XtNtitle , (XtArgVal) "XGoban : comment" ); xtargc++;
- XtSetArg (args[xtargc], XtNiconName , (XtArgVal) "Comment" ); xtargc++;
-
- c_toplevel = XtCreatePopupShell ("comment", applicationShellWidgetClass, w_toplevel, args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNwidth , (XtArgVal) 540 ); xtargc++;
- XtSetArg (args[xtargc], XtNheight , (XtArgVal) 200 ); xtargc++;
- XtSetArg (args[xtargc], XtNscrollVertical , (XtArgVal) XawtextScrollAlways ); xtargc++;
- XtSetArg (args[xtargc], XtNwrap , (XtArgVal) XawtextWrapWord ); xtargc++;
- XtSetArg (args[xtargc], XtNeditType , (XtArgVal) XawtextRead ); xtargc++;
- XtSetArg (args[xtargc], XtNdisplayCaret , (XtArgVal) False ); xtargc++;
-
- c_comment = XtCreateManagedWidget ("commentText", asciiTextWidgetClass , c_toplevel , args, xtargc);
-
- makeDialogWindow (w_toplevel, app_context);
- makeEventWindow (w_toplevel, app_context);
-
- XtAppAddActions (app_context, actions, XtNumber(actions));
- XawSimpleMenuAddGlobalActions (app_context);
-
- XtRegisterGrabAction (SelectDiagram, True, (ButtonPressMask | ButtonReleaseMask), GrabModeAsync, GrabModeAsync);
- XtRealizeWidget (w_toplevel);
-
- /*
- * Second display
- */
-
- if (current_mode == EditMode) {
- if (app_data.white_dsp != NULL) {
- second_display = XtOpenDisplay (app_context, app_data.white_dsp, NULL, ApplicationName,
- options, XtNumber (options), &argc, argv);
-
- w_second_toplevel = XtAppCreateShell (argv[0], ApplicationName, applicationShellWidgetClass, second_display, NULL, 0);
- second_player = SG_WhiteStone;
- }
-
- else if (app_data.black_dsp != NULL) {
- second_display = XtOpenDisplay (app_context, app_data.black_dsp, NULL, ApplicationName,
- options, XtNumber (options), &argc, argv);
-
- w_second_toplevel = XtAppCreateShell (argv[0], ApplicationName, applicationShellWidgetClass, second_display, NULL, 0);
- second_player = SG_BlackStone;
- }
-
- if (w_second_toplevel != NULL) {
-
- window = RootWindowOfScreen (XtScreen (w_second_toplevel));
-
- title = second_player == SG_BlackStone ? "XGoban : Black" : "XGoban : White";
- icon_title = second_player == SG_BlackStone ? "Black" : "White";
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNiconPixmap, icon_pixmap ); xtargc++;
- XtSetArg (args[xtargc], XtNtitle , title ); xtargc++;
- XtSetArg (args[xtargc], XtNiconName , icon_title ); xtargc++;
-
- XtSetValues (w_second_toplevel, args, xtargc);
-
- title = second_player == SG_BlackStone ? "XGoban : White" : "XGoban : Black";
- icon_title = second_player == SG_BlackStone ? "White" : "Black";
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNtitle , title ); xtargc++;
- XtSetArg (args[xtargc], XtNiconName , icon_title ); xtargc++;
-
- XtSetValues (w_toplevel, args, xtargc);
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNtranslations , (XtArgVal) XtParseTranslationTable (translations_table)); xtargc++;
- XtSetArg (args[xtargc], XtNpointSize , (XtArgVal) app_data.point_size ); xtargc++;
- XtSetArg (args[xtargc], XtNautoRedisplay , (XtArgVal) False ); xtargc++;
-
- w_second_goban = XtCreateManagedWidget ("goban" , gobanWidgetClass , w_second_toplevel, args, xtargc);
-
- XtRealizeWidget (w_second_toplevel);
-
- current_mode = PlayMode;
- }
- }
-
- /*
- * Black and White options : play a game
- */
-
- if (current_mode == EditMode) {
- if (app_data.black != NULL) {
- current_mode = PlayMode;
- edit = True;
-
- if (strcmp (app_data.black, "wally") == 0)
- black_player = Wally;
- else if (strcmp (app_data.black, "gnugo") == 0)
- black_player = Gnugo;
- }
-
- if (app_data.white != NULL) {
- current_mode = PlayMode;
- edit = True;
-
- if (strcmp (app_data.white, "wally") == 0)
- PopupDialog (w_toplevel, NULL, WallyWhitePlayWarning);
- else if (strcmp (app_data.white, "gnugo") == 0)
- white_player = Gnugo;
- }
- }
-
- /*
- * File option
- */
-
- file_name[0] = '\0';
-
- if (file != NULL) {
- (void) strcpy (file_name, file);
-
- if (current_mode != PlayMode)
- if (LoadFile (NULL, NULL, file) == True) {
- app_data.handicap = 0;
- app_data.size = 19;
- }
-
- else {
- (void) fprintf (stderr, "XGoban : can't open file : %s\n", file);
- (void) exit (1);
- }
- }
-
- /*
- * Create first node
- */
-
- if (tree == NULL) {
- tree = SG_MakeNode (NULL, SG_Event);
- current_node = tree;
-
- if (current_mode != PlayMode) Edit (True);
- }
-
- if (current_mode == PlayMode) {
- switch (black_player) {
- case Gnugo : SG_MakeProperty (tree, SG_PlayerBlack, (long) "gnugo"); break;
- case Wally : SG_MakeProperty (tree, SG_PlayerBlack, (long) "wally"); break;
- case Human :
- if (app_data.black != NULL)
- SG_MakeProperty (tree, SG_PlayerBlack, (long) app_data.black);
- break;
- }
-
- switch (white_player) {
- case Gnugo : SG_MakeProperty (tree, SG_PlayerWhite, (long) "gnugo"); break;
- case Wally : SG_MakeProperty (tree, SG_PlayerWhite, (long) "wally"); break;
- case Human :
- if (app_data.white != NULL)
- SG_MakeProperty (tree, SG_PlayerWhite, (long) app_data.white);
- break;
- }
- }
-
- /*
- * Size option
- */
-
- if (app_data.size > 1 && app_data.size < 19) {
- if (black_player == Wally && app_data.size != 9 && app_data.size != 13 && app_data.size != 19) {
- PopupDialog (w_toplevel, NULL, WallyBadSizeWarning);
- app_data.size = 9;
- }
-
- SG_MakeProperty (current_node, SG_SiZe, (long) app_data.size);
-
- modified = True;
- if (current_mode != PlayMode) Edit (True);
- }
-
- else
- app_data.size = 19;
-
- board_size = app_data.size;
-
- /*
- * Handicap option
- */
-
- current_node->player = SG_BlackStone;
-
- if (app_data.handicap > 1) {
- int x;
- int y;
- int h;
- char *ptr = stars[app_data.size - 2];
- unsigned char *setup;
-
- if (black_player == Wally && app_data.handicap != 9) {
- PopupDialog (w_toplevel, NULL, WallyBadHandicapWarning);
- app_data.handicap = 9;
- }
-
- if (*ptr == '\0') {
- PopupDialog (w_toplevel, NULL, BadHandicapWarning);
- app_data.handicap = 0;
- }
-
- else {
- setup = current_node->setup = (unsigned char *) malloc ((unsigned) 2 * app_data.handicap + 1);
-
- for (h = 0; h < app_data.handicap && *ptr != '\0'; h++) {
- x = *ptr++;
- y = *ptr++;
-
- if (h == 4 && (app_data.handicap == 6 || app_data.handicap == 8)) {
- x = *ptr++;
- y = *ptr++;
- }
-
- *setup++ = SG_SETB | (x - 'a' + 1);
- *setup++ = SG_SETB | (y - 'a' + 1);
- }
-
- if (h != app_data.handicap) {
- PopupDialog (w_toplevel, NULL, RemainingStonesWarning);
- app_data.handicap -= h;
- }
-
- *setup++ = SG_EOS;
- current_node->player = SG_WhiteStone;
-
- modified = True;
- if (current_mode != PlayMode) Edit (True);
- }
- }
-
- else
- app_data.handicap = 0;
-
- handicap = app_data.handicap;
-
- /*
- * Play first node and go...
- */
-
- GbClearBoard (w_goban);
-
- switch (current_mode) {
- case PlayMode :
- startGame (app_context);
- break;
-
- case EditMode :
- XtPopup (c_toplevel, XtGrabNone);
- break;
-
- case MailMode :
- XtPopup (c_toplevel, XtGrabNone);
-
- while (current_node->down != NULL) {
- Play (current_node);
- ShowProperty (current_node);
- HideTmpProperty (current_node);
-
- current_node = current_node->down;
- }
-
- mail_node = current_node;
- break;
-
- default :
- break;
- }
-
- Play (current_node);
- ShowProperty (current_node);
- RedisplayBoard ();
-
- XtAppMainLoop (app_context);
-
- /* NOTREACHED */
- }
-
- /*******************************************************************************************************
- */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'action.c'
- then
- echo shar: will not over-write existing file "'action.c'"
- else
- cat << \SHAR_EOF > 'action.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/StringDefs.h>
-
- #include <X11/Xaw/SimpleMenu.h>
- #include <X11/Xaw/SmeBSB.h>
- #include <X11/cursorfont.h>
-
- #include "xgoban.h"
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void NextComment (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- Arg arg;
- Boolean no_beep = False;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- if (current_node->down != NULL) {
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) True ); XtSetValues (w_goban, &arg, 1);
-
- do {
- HideTmpProperty (current_node);
-
- current_node = current_node->down;
-
- Play (current_node);
- ShowProperty (current_node);
-
- if (SG_GetProperty (current_node, SG_Comment) != NULL) {
- no_beep = True;
- break;
- }
-
- } while (current_node->down != NULL && current_node->right == NULL);
-
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) False); XtSetValues (w_goban, &arg, 1);
- }
-
- if (beep >= -100 && no_beep == False)
- XBell (XtDisplay (w), beep);
- break;
-
- default : break;
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void PreviousComment (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr tmp;
- Arg arg;
- Boolean no_beep = False;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) True ); XtSetValues (w_goban, &arg, 1);
-
- do {
- tmp = current_node;
- while (tmp->left != NULL) tmp = tmp->left;
-
- if (tmp->up != NULL) {
- Unplay (current_node);
- HideProperty (current_node);
-
- current_node = tmp->up;
-
- ShowTmpProperty (current_node);
- }
-
- if (SG_GetProperty (current_node, SG_Comment) != NULL) {
- no_beep = True;
- break;
- }
-
- } while (tmp->up != NULL && current_node->left == NULL && current_node->right == NULL);
-
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) False); XtSetValues (w_goban, &arg, 1);
-
- if (beep >= -100 && no_beep == False)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void NextVariationBranch (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- Arg arg;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- if (current_node->down != NULL) {
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) True ); XtSetValues (w_goban, &arg, 1);
-
- HideTmpProperty (current_node);
-
- current_node = current_node->down;
-
- Play (current_node);
- ShowProperty (current_node);
-
- while (current_node->down != NULL && current_node->right == NULL) {
- HideTmpProperty (current_node);
-
- current_node = current_node->down;
-
- Play (current_node);
- ShowProperty (current_node);
- }
-
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) False); XtSetValues (w_goban, &arg, 1);
- }
-
- else if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void PreviousVariationBranch (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr tmp;
- Boolean no_beep = False;
- Arg arg;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) True ); XtSetValues (w_goban, &arg, 1);
-
- do {
- tmp = current_node;
- while (tmp->left != NULL) tmp = tmp->left;
-
- if (tmp->up != NULL) {
- Unplay (current_node);
- HideProperty (current_node);
-
- current_node = tmp->up;
- no_beep = True;
-
- ShowTmpProperty (current_node);
- }
- } while (tmp->up != NULL && current_node->left == NULL && current_node->right == NULL);
-
- XtSetArg (arg, XtNautoRedisplay, (XtArgVal) False); XtSetValues (w_goban, &arg, 1);
-
- if (beep >= -100 && no_beep == False)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void PreviousMove (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr tmp = current_node;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- while (tmp->left != NULL)
- tmp = tmp->left;
-
- if (tmp->up != NULL) {
- Unplay (current_node);
- HideProperty (current_node);
-
- current_node = tmp->up;
-
- ShowTmpProperty (current_node);
- RedisplayBoard ();
-
- return;
- }
-
- if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void Exit (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- HideTmpProperty (current_node);
- ShowTmpProperty (current_node);
-
- switch (current_mode) {
- case EditMode :
- PopupDialog (w, event, modified == True ? SaveBeforeQuitDialog : ReallyQuitDialog);
- break;
- case PlayMode :
- PopupDialog (w, event, StopGameBeforeQuitDialog);
- break;
- case MailMode :
- PopupDialog (w, event, mail_node->down == NULL ? MailNoMoveDialog : MailConfirmMoveDialog);
- break;
- }
- }
-
- /*******************************************************************************************************
- */
-
-
- /* ARGSUSED */
-
- void destroyMenu (w, client_data, call_data)
- Widget w;
- XtPointer client_data;
- XtPointer call_data;
- {
- if (w_menu != NULL) {
- XtDestroyWidget (w_menu);
- w_menu = NULL;
- }
- }
-
- /* ARGSUSED */
-
- void menuAction (w, client_data, call_data)
- Widget w;
- XtPointer client_data;
- XtPointer call_data;
- {
- SG_NodePtr tmp = current_node;
- char mark = (int) client_data - 'A';
-
- while (tmp->left != NULL)
- tmp = tmp->left;
-
- while (mark-- != 0)
- tmp = tmp->right;
-
-
- Unplay (current_node);
- HideProperty (current_node);
-
- current_node = tmp;
-
- Play (current_node);
- ShowProperty (current_node);
- RedisplayBoard ();
- }
-
- /* ARGSUSED */
-
- void SelectDiagram (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- Widget entry;
- Arg args[4];
- int xtargc;
- SG_NodePtr tmp = current_node;
- SG_PropertyPtr property;
- String nparams[1];
- char buffer[256];
- char mark = 'A';
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - selectDiagram : This action routine requires a button press event.");
- return;
- }
-
- if (*num_params != 0)
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - selectDiagram : This action routine requires no argument.");
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- while (tmp->left != NULL)
- tmp = tmp->left;
-
- if (tmp->right == NULL) {
- if (beep >= -100)
- XBell (XtDisplay (w), beep);
- return;
- }
-
- if (w_menu == NULL) {
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNlabel , " Variations "); xtargc++;
-
- w_menu = XtCreatePopupShell ("variations", simpleMenuWidgetClass, w_goban, args, xtargc);
-
- entry = XtNameToWidget (w_menu, "menuLabel");
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNheight , 32 ); xtargc++;
- XtSetValues (entry, args, xtargc);
-
- while (tmp != NULL) {
- property = SG_GetProperty (tmp, SG_nodeName);
-
- if (property != NULL && property->data.pvalue != NULL)
- sprintf (buffer, "%c : %s", mark, property->data.pvalue);
-
- else
- switch (tmp->type) {
- case SG_EventType :
- sprintf (buffer, "%c : (Event)", mark);
- break;
-
- case SG_DiagramType :
- sprintf (buffer, "%c : (Diagram)",
- mark);
- break;
-
- case SG_MoveType :
- if (tmp->x != 0 && tmp->y != 0)
- sprintf (buffer, "%c : %s %c%d",
- mark,
- tmp->color == SG_BlackStone ? "Black" : "White",
- tmp->x + 'A' + (tmp->x < 9 ? -1 : 0),
- tmp->y);
- else
- sprintf (buffer, "%c : %s passes",
- mark,
- tmp->color == SG_BlackStone ? "Black" : "White");
- break;
- }
-
- xtargc = 0;
- XtSetArg (args[xtargc], XtNleftMargin, 8); xtargc++;
-
- entry = XtCreateManagedWidget (buffer, smeBSBObjectClass, w_menu, args, xtargc);
-
- XtAddCallback (entry, XtNcallback, menuAction, (XtPointer) mark);
-
- if (tmp == current_node) {
- XtSetArg (args[0], XtNpopupOnEntry, entry);
- XtSetValues (w_menu, args, 1);
- }
-
- mark++;
- tmp = tmp->right;
- }
- }
-
- XtAddCallback (w_menu, XtNpopdownCallback, destroyMenu, (XtPointer) NULL);
-
- nparams[0] = "variations";
-
- XtCallActionProc (w_goban, "XawPositionSimpleMenu", event, nparams, 1);
- XtCallActionProc (w_goban, "MenuPopup" , event, nparams, 1);
-
- return;
- }
- }
-
- /*******************************************************************************************************
- */
-
-
- /* ARGSUSED */
-
- void SelectVariation (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- char ch;
- SG_NodePtr tmp = current_node;
-
- if (*num_params != 1) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - selectVariation : This action routine requires one argument.");
- return;
- }
-
- ch = params[0][0];
-
- if (ch < 'a' && ch > 'z' && ch < 'A' && ch > 'Z') {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - selectVariation : argument should range between 'A' and 'Z'.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- ch = tolower (ch) - 'a';
-
- while (tmp->left != NULL)
- tmp = tmp->left;
-
- if (tmp->right != NULL) {
- while (tmp != NULL && ch != 0) {
- ch--;
- tmp = tmp->right;
- }
-
- if (ch == 0 && tmp != NULL) {
- if (tmp != current_node) {
- Unplay (current_node);
- HideProperty (current_node);
-
- current_node = tmp;
-
- Play (current_node);
- ShowProperty (current_node);
- RedisplayBoard ();
- }
-
- return;
- }
- }
-
- if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void Dialog (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- if (*num_params != 1) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - dialog : This action routine requires one argument.");
- return;
- }
-
- switch (current_mode) {
- case EditMode :
- switch (params[0][0]) {
- case 'E' : case 'e' : PopupDialog (w, event, EditDialog ); break;
- case 'L' : case 'l' : PopupDialog (w, event, modified == True ? SaveBeforeLoadDialog : LoadDialog); break;
- case 'N' : case 'n' : PopupDialog (w, event, NodeNameDialog); break;
- case 'S' : case 's' : PopupDialog (w, event, SaveAsDialog ); break;
- case 'H' : case 'h' : PopupDialog (w, event, HelpDialog ); break;
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - dialog : Argument should be Save, Load, Edit, Help or NodeName.");
- }
- break;
-
- case PlayMode :
- switch (params[0][0]) {
- case 'E' : case 'e' : PopupDialog (w, event, StopGameDialog); break;
- case 'S' : case 's' : PopupDialog (w, event, SaveAsDialog ); break;
- case 'H' : case 'h' : PopupDialog (w, event, HelpDialog ); break;
- case 'N' : case 'n' :
- case 'L' : case 'l' :
- if (beep >= -100)
- XBell (XtDisplay (w), beep); break;
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - dialog : Argument should be Save, Load, Edit, Help or NodeName.");
- }
-
- case MailMode :
- switch (params[0][0]) {
- case 'N' : case 'n' : PopupDialog (w, event, NodeNameDialog); break;
- case 'S' : case 's' : PopupDialog (w, event, SaveAsDialog ); break;
- case 'H' : case 'h' : PopupDialog (w, event, HelpDialog ); break;
- case 'E' : case 'e' :
- case 'L' : case 'l' :
- if (beep >= -100)
- XBell (XtDisplay (w), beep); break;
-
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - dialog : Argument should be Save, Load, Edit, Help or NodeName.");
- }
- break;
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void NextMove (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- Position x;
- Position y;
- SG_NodePtr tmp = current_node;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- if (event->type == ButtonPress) {
-
- if (current_node->type == SG_MoveType) {
- while (tmp->left != NULL)
- tmp = tmp->left;
-
- if (tmp->right != NULL) {
-
- x = (Position) ((XButtonPressedEvent *) event)->x;
- y = (Position) ((XButtonPressedEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE) {
-
- while (tmp != NULL) {
- if (tmp->type == SG_MoveType && tmp->color == current_node->color &&
- (Position) tmp->x == x && (Position) tmp->y == y) {
-
- Unplay (current_node);
- HideProperty (current_node);
-
- current_node = tmp;
-
- Play (current_node);
- ShowProperty (current_node);
- RedisplayBoard ();
-
- return;
- }
-
- tmp = tmp->right;
- }
- }
- }
- }
- }
-
- if (current_node->down != NULL) {
- HideTmpProperty (current_node);
-
- current_node = current_node->down;
-
- Play (current_node);
- ShowProperty (current_node);
- RedisplayBoard ();
- }
-
- else if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void MakeVariationDiagram (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr node;
-
- if (*num_params != 0)
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - makeVariationDiagram : This action routine requires no argument.");
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog); return; }
-
- node = SG_MakeNode (current_node, current_node->type == SG_EventType ? SG_Event : SG_VariationDiagram);
-
- if (node == NULL) {
- PopupDialog (w, event, MemoryErrorDialog);
- return;
- }
-
- node->player = current_node->player;
- modified = True;
-
- Unplay (current_node);
- HideProperty (current_node);
-
- current_node = node;
- current_mode = DiagramMode;
-
- StartDiagram ();
-
- Play (current_node);
- ShowProperty (current_node);
- RedisplayBoard ();
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void Add (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- Position x;
- Position y;
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - add : This action routine requires a ButtonPress event.");
- return;
- }
-
- if (*num_params != 1) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - add : This action routine requires one argument.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case DiagramMode :
-
- x = (Position) ((XButtonPressedEvent *) event)->x;
- y = (Position) ((XButtonPressedEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE ) {
-
- switch (params[0][0]) {
- case 'B' : case 'b' : AddStone (x, y, SG_BlackStone); GbSetPoint (w_goban, x, y, GbBlackStone); break;
- case 'W' : case 'w' : AddStone (x, y, SG_WhiteStone); GbSetPoint (w_goban, x, y, GbWhiteStone); break;
- case 'E' : case 'e' : AddStone (x, y, SG_EmptyPoint); GbSetPoint (w_goban, x, y, GbEmptyPoint); break;
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - add : Argument should be Black, White or Empty.");
- return;
- }
-
- modified = True;
- RedisplayBoard ();
- }
-
- else if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void SetPlayer (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- int player;
-
- if (*num_params != 1) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - player : This action routine requires one argument.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog); return; }
-
- switch (params[0][0]) {
- case 'B' : case 'b' : player = SG_BlackStone; break;
- case 'W' : case 'w' : player = SG_WhiteStone; break;
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - player : Argument should be Black or White.");
- return;
- }
-
- if (strict == True) {
- if (current_node->type == SG_MoveType) {
- PopupDialog (w, event, PlayerNodeErrorWarning);
- return;
- }
-
- else if (current_node->down != NULL) {
- PopupDialog (w, event, PlayerMoveErrorWarning);
- return;
- }
- }
-
- HideProperty (current_node);
-
- current_node->player = player;
- modified = True;
-
- ShowProperty (current_node);
- RedisplayBoard ();
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void Letter (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- unsigned char letter[3];
- Position x;
- Position y;
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - letter : This action routine requires a ButtonPress event.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog); return; }
-
- x = (Position) ((XButtonPressedEvent *) event)->x;
- y = (Position) ((XButtonPressedEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE) {
-
- letter[0] = x;
- letter[1] = y;
- letter[2] = SG_EOS;
-
- HideTmpProperty (current_node);
- SG_MakeProperty (current_node, SG_Letters, letter);
- ShowTmpProperty (current_node);
- RedisplayBoard ();
-
- modified = True;
- }
-
- else if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void Mark (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- unsigned char mark[3];
- Position x;
- Position y;
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - mark : This action routine requires a ButtonPress event.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog); return; }
-
- x = (Position) ((XButtonPressedEvent *) event)->x;
- y = (Position) ((XButtonPressedEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE) {
-
- mark[0] = x;
- mark[1] = y;
- mark[2] = SG_EOS;
-
- HideTmpProperty (current_node);
- SG_MakeProperty (current_node, SG_Marked, mark);
- ShowTmpProperty (current_node);
- RedisplayBoard ();
-
- modified = True;
- }
-
- else if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void DeleteMark (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_PropertyPtr property;
- unsigned char *ptr;
- Position x;
- Position y;
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - deleteMark : This action routine requires a ButtonPress event.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog); return; }
-
- x = (Position) ((XButtonPressedEvent *) event)->x;
- y = (Position) ((XButtonPressedEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE) {
-
- HideTmpProperty (current_node);
-
- property = SG_GetProperty (current_node, SG_Letters);
-
- if (property != NULL && (ptr = property->data.pvalue) != NULL) {
-
- while (*ptr != SG_EOS) {
- if ((*ptr & 0x3f) == x && (*(ptr + 1) & 0x3f) == y) {
- *ptr = *(ptr + 1) = 0;
- modified = True;
- }
- ptr += 2;
- }
- }
-
- property = SG_GetProperty (current_node, SG_Marked);
-
- if (property != NULL && (ptr = property->data.pvalue) != NULL) {
-
- while (*ptr != SG_EOS) {
- if ((*ptr & 0x3f) == x && (*(ptr + 1) & 0x3f) == y) {
- *ptr = *(ptr + 1) = 0;
- modified = True;
- }
- ptr += 2;
- }
- }
-
- ShowTmpProperty (current_node);
- RedisplayBoard ();
- }
-
- else if (beep >= -100)
- XBell (XtDisplay (w), beep);
- }
- }
-
- /*******************************************************************************************************
- */
-
- Boolean delete_confirm = False;
-
- /* ARGSUSED */
-
- void DeleteMove (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr node = current_node;
- Boolean replay = False;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog ); return; }
- if (delete_confirm == False) { PopupDialog (w, event, ReallyDeleteDialog); return; }
-
- delete_confirm = False;
-
- Unplay (node);
- HideProperty (node);
-
- if (node->left != NULL)
- { current_node = node->left ; replay = True; }
- else if (node->right != NULL)
- { current_node = node->right; replay = True; }
- else if (node->up != NULL)
- current_node = node->up;
- else
- tree = current_node = NULL;
-
- SG_RemoveNode (node);
- SG_FreeNode (node);
-
- if (tree == NULL)
- { current_node = tree = SG_MakeNode ((SG_NodePtr) NULL, SG_Event); replay = True; }
-
- if (replay == True) {
- Play (current_node);
- ShowProperty (current_node);
- }
-
- else
- ShowTmpProperty (current_node);
-
- RedisplayBoard ();
-
- modified = True;
-
- if (current_mode == MailMode) {
- Edit (False);
- edit = True;
- }
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void Pass (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr node;
-
- if (current_node != NULL) {
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog); return; }
-
- if (current_node->down == NULL)
- goto play_move;
- else
- PopupDialog (w, event, ReplaceNodeDialog);
- break;
-
- case PlayMode :
- if ((current_node->player == SG_BlackStone && black_player == Human) ||
- (current_node->player == SG_WhiteStone && white_player == Human))
- goto play_move;
- break;
- }
- return;
-
- play_move :
- HideTmpProperty (current_node);
-
- node = SG_MakeNode (current_node, SG_Move);
- node->x = 0;
- node->y = 0;
- node->color = current_node->player;
-
- Play (node);
-
- modified = True;
- current_node = node;
-
- ShowProperty (current_node);
- RedisplayBoard ();
-
- switch (current_mode) {
- case PlayMode : signalMove (node); break;
- case MailMode : Edit (True); break;
- }
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void MakeMove (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr node;
- int player;
- int play;
- Position x;
- Position y;
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - makeMove : This action routine requires a ButtonPress event.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
- if (edit == False) { PopupDialog (w, event, EditDialog ); return; }
- if (current_node->down != NULL ) { PopupDialog (w, event, ReplaceNodeDialog); return; }
-
- goto play_move;
-
- case PlayMode :
- if (current_node->player == SG_BlackStone && black_player != Human) break;
- if (current_node->player == SG_WhiteStone && white_player != Human) break;
- if (w_second_toplevel != NULL) {
- if (w == w_second_goban && current_node->player != second_player) break;
- if (w == w_goban && current_node->player == second_player) break;
- }
-
- goto play_move;
- }
-
- if (beep >= -100)
- XBell (XtDisplay (w_goban), beep);
-
- return;
-
- play_move :
- x = (Position) ((XButtonPressedEvent *) event)->x;
- y = (Position) ((XButtonPressedEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE) {
-
- HideTmpProperty (current_node);
-
- player = current_node->player;
- node = SG_MakeNode (current_node, SG_Move);
-
- node->x = x;
- node->y = y;
- node->color = player;
-
- play = Play (node);
-
- switch (play) {
- case SG_PlayIllegal : PopupDialog (w, event, IllegalMoveDialog); break;
- case SG_PlayKo : PopupDialog (w, event, KoMoveDialog ); break;
- case SG_PlaySuicide : PopupDialog (w, event, SuicideMoveDialog); break;
- }
-
- if (play != SG_OK) {
- SG_RemoveNode (node);
- SG_FreeNode (node);
- ShowTmpProperty (current_node);
- }
-
- else {
- modified = True;
- current_node = node;
-
- ShowProperty (current_node);
- RedisplayBoard ();
-
- switch (current_mode) {
- case PlayMode : signalMove (node); break;
- case MailMode : Edit (True); break;
- }
- }
- }
-
- else if (beep >= -100)
- XBell (XtDisplay (w_goban), beep);
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void MakeVariation (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr tmp = current_node;
- SG_NodePtr node;
- int player;
- int play;
- Position x;
- Position y;
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - makeVariation : This action routine requires a ButtonPress event.");
- return;
- }
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- if (current_node->type != SG_EventType) {
-
- x = (Position) ((XButtonPressedEvent *) event)->x;
- y = (Position) ((XButtonPressedEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE) {
-
- tmp = current_node;
- while (tmp->left != NULL) tmp = tmp->left;
-
- player = tmp->up->player;
-
- tmp = current_node;
- while (tmp->left != NULL) tmp = tmp->left;
-
- while (tmp != NULL) {
- if (tmp->type == SG_MoveType && tmp->color == player &&
- (Position) tmp->x == x && (Position) tmp->y == y)
- return;
-
- tmp = tmp->right;
- }
-
- HideProperty (current_node);
- Unplay (current_node);
-
- node = SG_MakeNode (current_node, SG_VariationMove);
-
- node->x = x;
- node->y = y;
- node->color = player;
-
- play = Play (node);
-
- switch (play) {
- case SG_PlayIllegal : PopupDialog (w, event, IllegalMoveDialog); break;
- case SG_PlayKo : PopupDialog (w, event, KoMoveDialog ); break;
- case SG_PlaySuicide : PopupDialog (w, event, SuicideMoveDialog); break;
-
- }
-
- if (play != SG_OK) {
- SG_RemoveNode (node);
- SG_FreeNode (node);
- Play (current_node);
- ShowProperty (current_node);
- }
-
- else {
- modified = True;
- current_node = node;
- ShowProperty (current_node);
- RedisplayBoard ();
- }
- }
- }
- }
- }
-
- /*******************************************************************************************************
- */
-
- /* ARGSUSED */
-
- void MakeVariationPass (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- SG_NodePtr tmp = current_node;
- SG_NodePtr node;
- int player;
- Position x;
- Position y;
-
- if (current_node != NULL)
- switch (current_mode) {
- case EditMode :
- case MailMode :
-
- if (current_node->type != SG_EventType) {
-
- x = 0;
- y = 0;
-
- tmp = current_node;
- while (tmp->left != NULL) tmp = tmp->left;
-
- player = tmp->up->player;
-
- tmp = current_node;
- while (tmp->left != NULL) tmp = tmp->left;
-
- while (tmp != NULL) {
- if (tmp->type == SG_MoveType && tmp->color == player &&
- (Position) tmp->x == x && (Position) tmp->y == y)
- return;
-
- tmp = tmp->right;
- }
-
- HideProperty (current_node);
- Unplay (current_node);
-
- node = SG_MakeNode (current_node, SG_VariationMove);
-
- node->x = x;
- node->y = y;
- node->color = player;
-
- (void) Play (node);
-
- current_node = node;
- modified = True;
-
- ShowProperty (current_node);
- RedisplayBoard ();
- }
- }
- }
-
- /*******************************************************************************************************
- */
-
- static Dimension size;
- static Position top;
- static Position left;
- static Position bottom;
- static Position right;
-
- static Position u_top;
- static Position u_left;
- static Position u_bottom;
- static Position u_right;
-
- /* ARGSUSED */
-
- void SetMode (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- Mode md;
- Arg args[8];
- unsigned char *ptr = NULL;
-
- if (current_node != NULL) {
- if (*num_params != 1) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - mode : This action routine requires one argument.");
- return;
- }
-
- switch (params[0][0]) {
- case 'E' : case 'e' : md = EditMode ; break;
- case 'D' : case 'd' : md = DiagramMode; break;
- case 'S' : case 's' : md = SizeMode ; break;
- case 'V' : case 'v' : md = ViewMode ; break;
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - mode : Argument should be Edit, Read, View, Diagram or Size.");
- return;
- }
-
- if (md != EditMode && edit == False ) { PopupDialog (w, event, EditDialog ); return; }
-
- switch (md) {
- case EditMode :
-
- switch (current_mode) {
-
- case SizeMode :
- XtSetArg (args[0], XtNgameSize , (XtArgVal) size);
- XtSetValues (w_goban, args, 1);
-
- case ViewMode :
-
- XtSetArg (args[0], XtNviewTop , (XtArgVal) top );
- XtSetArg (args[1], XtNviewLeft , (XtArgVal) left );
- XtSetArg (args[2], XtNviewBottom, (XtArgVal) bottom);
- XtSetArg (args[3], XtNviewRight , (XtArgVal) right );
- XtSetValues (w_goban, args, 4);
-
- RedisplayBoard ();
- break;
-
- case DiagramMode :
- ptr = EndDiagram ();
-
- if (ptr != NULL) {
-
- current_node->setup = ptr;
-
- Play (current_node);
- ShowProperty (current_node);
- }
- break;
-
- default :
- if (beep >= -100)
- XBell (XtDisplay (w_goban), beep);
- return;
- }
-
- md = (mail_node == NULL) ? EditMode : MailMode;
-
- break;
-
- case DiagramMode :
- if (current_mode != EditMode && current_mode != MailMode)
- { if (beep >= -100) XBell (XtDisplay (w_goban), beep); return; }
- if (current_node->type == SG_MoveType)
- { PopupDialog (w, event, DiagramBadNodeWarning); return; }
-
- Unplay (current_node);
- StartDiagram ();
- Play (current_node);
-
- break;
-
- case SizeMode :
- if (current_mode != EditMode) { if (beep >= -100) XBell (XtDisplay (w_goban), beep); return; }
- if (current_node->type != SG_EventType) { PopupDialog (w, event, SizeBadNodeWarning); return; }
- if (current_node->down != NULL ) { PopupDialog (w, event, RemoveStonesDialog); return; }
-
- HideProperty (current_node);
- Unplay (current_node);
-
- free (current_node->setup);
- current_node->setup = NULL;
-
- RedisplayBoard ();
-
- break;
-
- case ViewMode :
- if (current_mode != EditMode && current_mode != MailMode)
- { if (beep >= -100) XBell (XtDisplay (w_goban), beep); return; }
-
- XtSetArg (args[0], XtNgameSize , (XtArgVal) &size);
- XtGetValues (w_goban, args, 1);
-
- XtSetArg (args[0], XtNviewTop , (XtArgVal) &top );
- XtSetArg (args[1], XtNviewLeft , (XtArgVal) &left );
- XtSetArg (args[2], XtNviewBottom, (XtArgVal) &bottom);
- XtSetArg (args[3], XtNviewRight , (XtArgVal) &right );
- XtGetValues (w_goban, args, 4);
-
- HideProperty (current_node);
-
- XtSetArg (args[0], XtNviewTop , (XtArgVal) &u_top );
- XtSetArg (args[1], XtNviewLeft , (XtArgVal) &u_left );
- XtSetArg (args[2], XtNviewBottom, (XtArgVal) &u_bottom);
- XtSetArg (args[3], XtNviewRight , (XtArgVal) &u_right );
- XtGetValues (w_goban, args, 4);
-
- ShowProperty (current_node);
-
- XtSetArg (args[0], XtNviewTop , (XtArgVal) size);
- XtSetArg (args[1], XtNviewLeft , (XtArgVal) 1 );
- XtSetArg (args[2], XtNviewBottom, (XtArgVal) 1 );
- XtSetArg (args[3], XtNviewRight , (XtArgVal) size);
- XtSetValues (w_goban, args, 4);
-
- RedisplayBoard ();
- break;
-
- default :
- return;
- }
-
- current_mode = md;
-
- ShowCursor (current_node);
- }
- }
-
- /*******************************************************************************************************
- *
- * Drag a rectangle on screen to set property SiZe or VieW.
- * Must be called by user as 'drag(Start)' 'drag()' and 'drag(Stop)'.
- */
-
- static Position x0;
- static Position y0;
- static Position x1;
- static Position y1;
-
- static int drag_in_progress = 0;
- static GC drag_gc;
-
- void Drag (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
- {
- static Boolean gc_created = False;
-
- int size;
- Arg args[4];
- Position x;
- Position y;
- Position xmax;
- Position ymax;
- Dimension point_size;
- long value;
-
- if (current_mode == SizeMode || current_mode == ViewMode) {
-
- if (event->type != MotionNotify && event->type != ButtonPress && event->type != ButtonRelease) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - drag : This action routine requires a button event.");
- return;
- }
-
- if (gc_created == False) {
- XGCValues values;
-
- values.function = GXinvert;
- drag_gc = XCreateGC (XtDisplay (w_goban), XtWindow (w_goban), GCFunction, &values);
- gc_created = True;
- }
-
- switch (*num_params) {
-
- case 0 :
-
- /*
- * drag() : erase previous rectangle, update coordinates and redraw rectangle on screen.
- */
-
- if (event->type != MotionNotify) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - drag() : This action routine requires a MotionNotify event.");
- return;
- }
-
- if (drag_in_progress == 1) {
-
- x = (Position) ((XButtonEvent *) event)->x;
- y = (Position) ((XButtonEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) != TRUE) return;
-
- xmax = 19;
- ymax = 1;
-
- GbGetPositionFromStone (w_goban, &x , &y );
- GbGetPositionFromStone (w_goban, &xmax, &ymax);
-
- if (x > x0 && y > y0 && (x != x1 || y != y1)) {
-
- XtSetArg (args[0], XtNpointSize, &point_size);
- XtGetValues (w_goban, args, 1);
-
- if (x0 != x1 || y0 != y1)
- XDrawRectangle (XtDisplay (w), XtWindow (w), drag_gc,
- x0 - point_size / 2, y0 - point_size / 2,
- x1 - x0 + point_size, y1 - y0 + point_size);
-
- if (current_mode == SizeMode) {
- x = x0 + Min (xmax - x0, Min (ymax - y0, Max (x - x0, y - y0)));
- y = y0 + Min (xmax - x0, Min (ymax - y0, Max (x - x0, y - y0)));
- }
-
- x1 = x;
- y1 = y;
-
- XDrawRectangle (XtDisplay (w), XtWindow (w), drag_gc,
- x0 - point_size / 2, y0 - point_size / 2,
- x1 - x0 + point_size, y1 - y0 + point_size);
-
- XFlush (XtDisplay (w));
- }
- }
- break;
-
- case 1 :
-
- switch (params[0][2]) {
-
- case 'A' :
- case 'a' :
-
- /*
- * drag(Start) : initialize rectangle (x0 y0 x1 y1).
- */
-
- if (event->type != ButtonPress) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - drag(Start) : This action routine requires a ButtonPress event.");
- return;
- }
-
- x = (Position) ((XButtonEvent *) event)->x;
- y = (Position) ((XButtonEvent *) event)->y;
-
- if (GbGetStoneFromPosition (w_goban, &x, &y) == TRUE) {
-
- GbGetPositionFromStone (w_goban, &x, &y);
-
- x1 = x0 = x;
- y1 = y0 = y;
-
- XtSetArg (args[0], XtNcursor, XC_bottom_right_corner);
- XtSetValues (w_goban, args, 1);
-
- drag_in_progress = 1;
- }
- break;
-
- case 'O' :
- case 'o' :
-
- /*
- * drag(Stop) : erase rectangle on screen and create desired property.
- */
-
- if (event->type != ButtonRelease) {
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - drag(Stop) : This action routine requires a ButtonRelease event.");
- return;
- }
-
- if (drag_in_progress == 1) {
- XtSetArg (args[0], XtNpointSize, &point_size);
- XtGetValues (w_goban, args, 1);
-
- XDrawRectangle (XtDisplay (w), XtWindow (w), drag_gc,
- x0 - point_size / 2, y0 - point_size / 2,
- x1 - x0 + point_size, y1 - y0 + point_size);
-
- GbGetStoneFromPosition (w_goban, &x0, &y0);
- GbGetStoneFromPosition (w_goban, &x1, &y1);
-
- size = Max (x1 - x0 + 1, y0 - y1 + 1);
-
- switch (current_mode) {
-
- /*
- * Create SiZe property.
- */
-
- case SizeMode :
-
- if (size > 1 && size < 20) {
- XtSetArg (args[0], XtNgameSize , (XtArgVal) size);
- XtSetValues (w_goban, args, 1);
-
- value = ((long) size << 24) + (1 << 16) + (1 << 8) + (long) size;
-
- SG_MakeProperty (current_node, SG_SiZe, size );
- SG_MakeProperty (current_node, SG_VieW, value);
-
- modified = True;
- }
-
- break;
-
- /*
- * Create VieW property.
- */
-
- case ViewMode :
-
- if (y0 > y1 && x1 > x0) {
-
- XtSetArg (args[0], XtNviewTop , (XtArgVal) y0);
- XtSetArg (args[1], XtNviewLeft , (XtArgVal) x0);
- XtSetArg (args[2], XtNviewBottom, (XtArgVal) y1);
- XtSetArg (args[3], XtNviewRight , (XtArgVal) x1);
- XtSetValues (w_goban, args, 4);
-
- value = ((long) u_top << 24) + ((long) u_left << 16) + ((long) u_bottom << 8) + (long) u_right;
- SG_MakeProperty (current_node, SG_unVieW, value);
-
- value = ((long) y0 << 24) + ((long) x0 << 16) + ((long) y1 << 8) + (long) x1 ;
- SG_MakeProperty (current_node, SG_VieW , value);
-
- modified = True;
- }
- break;
- }
- }
-
- /*
- * Redisplay current node.
- */
-
- current_mode = (mail_node == NULL) ? EditMode : MailMode;
- drag_in_progress = 0;
-
- ShowCursor (current_node);
- RedisplayBoard ();
- break;
-
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - drag : Argument should be Start or Stop.");
- return;
- }
- break;
-
- default :
- XtAppWarning (XtWidgetToApplicationContext (w),
- "XGoban - drag : This action routine requires one or no argument.");
- return;
- }
- }
- }
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'misc.c'
- then
- echo shar: will not over-write existing file "'misc.c'"
- else
- cat << \SHAR_EOF > 'misc.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/StringDefs.h>
-
- #include <X11/cursorfont.h>
- #include <X11/Xaw/AsciiText.h>
- #include <X11/Xaw/Label.h>
-
- #include "xgoban.h"
-
- /*******************************************************************************************************
- *
- */
-
- void CenterWindow (w, button)
- Widget w;
- Widget button;
- {
- Display *display = XtDisplay (w);
- Window root;
- Window child;
- int rx;
- int ry;
- int bw;
- int ignore;
- unsigned int mask;
- Arg args[4];
- Dimension butw;
- Dimension buth;
- Dimension width;
- Dimension height;
- Position x;
- Position y;
- XWindowAttributes attr;
-
- if (XtIsRealized (w) == FALSE) XtRealizeWidget (w);
-
- XGetWindowAttributes (display, XtWindow (w), &attr);
- bw = attr.border_width;
- XGetWindowAttributes (display, RootWindowOfScreen (XtScreen (w)), &attr);
-
- XQueryPointer (display, XtWindow (w), &root, &child, &rx, &ry, &ignore, &ignore, &mask);
-
- XtSetArg (args[0], XtNwidth , (XtArgVal) &width );
- XtSetArg (args[1], XtNheight, (XtArgVal) &height);
-
- XtGetValues (w, args, 2);
-
- if (button != NULL) {
- XtSetArg (args[0], XtNx , (XtArgVal) &x );
- XtSetArg (args[1], XtNy , (XtArgVal) &y );
- XtSetArg (args[2], XtNwidth , (XtArgVal) &butw );
- XtSetArg (args[3], XtNheight , (XtArgVal) &buth );
-
- XtGetValues (button, args, 4);
-
- rx = rx - x - 3 * butw / 4;
- ry = ry - y - 2 * buth / 3;
- }
-
- else {
- rx = rx - width / 2;
- ry = ry - height / 2;
- }
-
- rx = (rx < 2) ? 2 : rx;
- rx = (rx > attr.width - width - 2 * bw - 4) ? attr.width - width - 2 * bw - 4 : rx;
-
- ry = (ry < 2) ? 2 : ry;
- ry = (ry > attr.height - height - 2 * bw - 4) ? attr.height - height - 2 * bw - 4 : ry;
-
- XtMoveWidget (w, rx, ry);
- }
-
- /*******************************************************************************************************
- *
- */
-
- void ShowCursor (node)
- SG_NodePtr node;
- {
- Arg args[2];
- int cursor = XC_question_arrow;
-
- switch (current_mode) {
-
- case EditMode :
- case PlayMode :
- case MailMode :
-
- if (node != NULL) {
-
- switch (node->type) {
-
- case SG_EventType :
- case SG_DiagramType :
- if (node->left != NULL || node->right != NULL)
- cursor = GbCGrayStone;
- else
- cursor = (node->player == SG_BlackStone) ? GbCBlackStone : GbCWhiteStone;
- break;
-
- case SG_MoveType :
- if (node->left != NULL || node->right != NULL)
- cursor = GbCGrayStone;
- else
- cursor = (node->color == SG_BlackStone) ? GbCWhiteStone : GbCBlackStone;
- break;
- }
- }
-
- else
- cursor = GbCGrayStone;
-
- break;
-
- case SizeMode :
- case ViewMode :
- cursor = XC_top_left_corner;
- break;
-
- case DiagramMode :
- cursor = XC_dot;
- break;
-
- default :
- return;
- }
-
- XtSetArg (args[0], XtNcursor, (XtArgVal) cursor);
- XtSetValues (w_goban, args, 1);
-
- if (w_second_goban != NULL)
- XtSetValues (w_second_goban, args, 1);
- }
-
- /*******************************************************************************************************
- *
- */
-
- Boolean LoadFile (w, event, name)
- Widget w;
- XEvent *event;
- char *name;
- {
- FILE *file;
- SG_NodePtr node;
- char tmp_name[1024];
- char *src = path;
- char *dst;
-
- if (*name == '/') {
- if ((file = fopen (name, "r")) == NULL)
- goto failed;
- }
-
- else
- do {
- dst = tmp_name;
-
- while (*src != ':' && *src != '\0')
- *dst++ = *src++;
-
- if (*src == '\0' && dst == tmp_name) {
- failed :
-
- if (w != NULL)
- PopupDialog (w, event, CantOpenFileDialog);
-
- return False;
- }
-
- *dst++ = '/';
- *dst++ = '\0';
-
- if (*src == ':') src++;
-
- (void) strcat (tmp_name, name);
- file = fopen (tmp_name, "r");
-
- } while (file == NULL);
-
- node = SG_ReadTree (file);
- fclose (file);
-
- if (node != NULL) {
- do {
- while (node->up != NULL)
- node = node->up;
- while (node->left != NULL)
- node = node->left;
- } while (node->up != NULL);
-
- SG_FreeNode (tree);
-
- tree = node;
- current_node = node;
- modified = False;
-
- (void) strcpy (file_name, tmp_name);
- }
-
- return True;
- }
-
- /*******************************************************************************************************
- */
-
- Boolean SaveFile (w, event, name)
- Widget w;
- XEvent *event;
- char *name;
- {
- FILE *file;
- char tmp_name[256];
- int saved;
-
- if (*name != '/')
- (void) strcpy (tmp_name, "./");
-
- (void) strcat (tmp_name, name);
- file = fopen (tmp_name, "w");
-
- if (file == NULL && w != NULL) {
- PopupDialog (w, event, CantOpenFileDialog);
- return False;
- }
-
- HideTmpProperty (current_node);
- ShowTmpProperty (current_node);
-
- saved = SG_WriteTree (tree, file, short_print == True ? 1 : 0);
- fclose (file);
-
- if (saved != 0 && w != NULL) {
- PopupDialog (w, event, CantOpenFileDialog);
- return False;
- }
-
- (void) strcpy (file_name, name);
- modified = False;
-
- return saved == 0 ? True : False;
- }
-
- /*******************************************************************************************************
- */
-
- void Edit (flag)
- Boolean flag;
- {
- Arg args[4];
-
- if (flag == True) {
- XtSetArg (args[0], XtNeditType , (XtArgVal) XawtextEdit );
- XtSetArg (args[1], XtNdisplayCaret , (XtArgVal) True );
-
- XtSetValues (c_comment, args, 2);
-
- edit = True;
- }
-
- else {
- XtSetArg (args[0], XtNeditType , (XtArgVal) XawtextRead );
- XtSetArg (args[1], XtNdisplayCaret , (XtArgVal) False );
-
- XtSetValues (c_comment, args, 2);
-
- edit = False;
- }
- }
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'display.c'
- then
- echo shar: will not over-write existing file "'display.c'"
- else
- cat << \SHAR_EOF > 'display.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include "xgoban.h"
-
- #include <X11/Shell.h>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
-
- /*******************************************************************************************************
- */
-
- void ShowTmpProperty (node)
- SG_NodePtr node;
- {
- SG_NodePtr tmp;
- char mark = 'A';
- char letter = 'a';
- Position x;
- Position y;
- SG_PropertyPtr property;
- unsigned char *ptr;
- Arg arg;
-
- if (node != NULL) {
- property = node->property;
-
- while (property != NULL) {
-
- switch (property->id) {
-
- case SG_Comment :
- if (property->data.pvalue != NULL)
- { XtSetArg (arg, XtNstring, (XtArgVal) property->data.pvalue); XtSetValues (c_comment, &arg, 1); }
- break;
-
- case SG_Letters :
- if ((ptr = property->data.pvalue) != NULL) {
-
- while (*ptr != SG_EOS) {
- x = (*ptr++ & 0x3f);
- y = (*ptr++ & 0x3f);
-
- if (x != 0 || y != 0) {
- GbSetMark (w_goban, x, y, letter, 0);
- if (w_second_goban != NULL)
- GbSetMark (w_second_goban, x, y, letter, 0);
- letter++;
- }
- }
- }
- break;
-
- case SG_Marked :
- if ((ptr = property->data.pvalue) != NULL) {
-
- while (*ptr != SG_EOS) {
- x = (*ptr++ & 0x3f);
- y = (*ptr++ & 0x3f);
-
- if (x != 0 || y != 0) {
- GbSetMark (w_goban, x, y, 0, GbMTriangleMark);
- if (w_second_goban != NULL)
- GbSetMark (w_second_goban, x, y, 0, GbMTriangleMark);
- }
- }
- }
- break;
-
- case SG_nodeName :
-
- if (property->data.pvalue != NULL) {
- XtSetArg (arg, XtNtitle, (XtArgVal) property->data.pvalue);
- XtSetValues (c_toplevel, &arg, 1);
- }
- break;
-
- case SG_GameName :
-
- if (property->data.pvalue != NULL) {
- XtSetArg (arg, XtNtitle, (XtArgVal) property->data.pvalue);
- XtSetValues (w_toplevel, &arg, 1);
- }
- break;
- }
-
- property = property->next;
- }
-
- switch (node->type) {
-
- case SG_EventType :
- case SG_DiagramType :
- break;
-
- case SG_MoveType :
- tmp = node;
-
- while (tmp->left != NULL)
- tmp = tmp->left;
-
- if (tmp->right != NULL)
- while (tmp != NULL) {
- if (tmp->type == SG_MoveType && tmp->color == node->color && tmp->x != 0 && tmp->y != 0) {
- GbSetMark (w_goban, tmp->x, tmp->y, mark, 0);
-
- if (w_second_goban != NULL)
- GbSetMark (w_second_goban, tmp->x, tmp->y, mark, 0);
- }
-
- mark++;
- tmp = tmp->right;
- }
-
- else if (autonum == TRUE) {
- GbSetNum (w_goban, node->x, node->y, node->num);
-
- if (w_second_goban != NULL)
- GbSetNum (w_second_goban, node->x, node->y, node->num);
- }
-
- break;
- }
- }
-
- ShowCursor (node);
- }
-
- /*******************************************************************************************************
- */
-
- void ShowProperty (node)
- SG_NodePtr node;
- {
- unsigned char *setup;
- int color;
- int x;
- int y;
- int view = 0;
- SG_PropertyPtr property;
- Position top;
- Position left;
- Position bottom;
- Position right;
- Arg args[4];
- long value;
-
- if (node != NULL) {
- property = node->property;
-
- while (property != NULL) {
- switch (property->id) {
-
- case SG_SiZe :
- XtSetArg (args[0], XtNgameSize, property->data.ivalue);
- XtSetValues (w_goban, args, 1);
- if (w_second_goban != NULL)
- XtSetValues (w_second_goban, args, 1);
- break;
-
- case SG_GameName :
- if (property->data.pvalue != NULL) {
- XtSetArg (args[0], XtNtitle, property->data.pvalue);
- XtSetValues (w_goban, args, 1);
- if (w_second_goban != NULL)
- XtSetValues (w_second_goban, args, 1);
- }
- break;
-
- case SG_VieW :
- XtSetArg (args[0], XtNviewTop , &top );
- XtSetArg (args[1], XtNviewLeft , &left );
- XtSetArg (args[2], XtNviewBottom, &bottom);
- XtSetArg (args[3], XtNviewRight , &right );
-
- XtGetValues (w_goban, args, 4);
- if (w_second_goban != NULL)
- XtGetValues (w_second_goban, args, 4);
-
- value = ((long) top << 24) + ((long) left << 16) + ((long) bottom << 8) + ((long) right);
-
- SG_MakeProperty (node, SG_unVieW, value);
-
- XtSetArg (args[0], XtNviewTop , (Position) ((property->data.ivalue >> 24)) );
- XtSetArg (args[1], XtNviewLeft , (Position) ((property->data.ivalue >> 16) & 0xff));
- XtSetArg (args[2], XtNviewBottom, (Position) ((property->data.ivalue >> 8) & 0xff));
- XtSetArg (args[3], XtNviewRight , (Position) ((property->data.ivalue ) & 0xff));
-
- XtSetValues (w_goban, args, 4);
- if (w_second_goban != NULL)
- XtSetValues (w_second_goban, args, 4);
-
- view++;
-
- break;
- }
-
- property = property->next;
- }
-
- switch (node->type) {
-
- case SG_EventType :
- GbClearBoard (w_goban);
- if (w_second_goban != NULL)
- GbClearBoard (w_second_goban);
-
- if (view == 0) {
- XtSetArg (args[0], XtNviewTop , 19);
- XtSetArg (args[1], XtNviewLeft , 0);
- XtSetArg (args[2], XtNviewBottom, 0);
- XtSetArg (args[3], XtNviewRight , 19);
-
- XtSetValues (w_goban, args, 4);
- if (w_second_goban != NULL)
- XtSetValues (w_second_goban, args, 4);
- }
-
- case SG_DiagramType :
- if ((setup = node->setup) != NULL)
- while (*setup != SG_EOS) {
- color = (*setup & 0xc0);
- x = (*setup++ & 0x3f);
- y = (*setup++ & 0x3f);
-
- switch (color) {
- case SG_SETB : GbSetPoint (w_goban, x, y, GbBlackStone); break;
- case SG_SETW : GbSetPoint (w_goban, x, y, GbWhiteStone); break;
- case SG_SETEB :
- case SG_SETEW : GbSetPoint (w_goban, x, y, GbEmptyPoint); break;
- }
-
- if (w_second_goban != NULL)
- switch (color) {
- case SG_SETB : GbSetPoint (w_second_goban, x, y, GbBlackStone); break;
- case SG_SETW : GbSetPoint (w_second_goban, x, y, GbWhiteStone); break;
- case SG_SETEB :
- case SG_SETEW : GbSetPoint (w_second_goban, x, y, GbEmptyPoint); break;
- }
- }
- break;
-
- case SG_MoveType :
- x = node->x;
- y = node->y;
- color = (int) ((node->color == SG_BlackStone) ? GbBlackStone : GbWhiteStone);
-
- GbSetPoint (w_goban, x, y, color);
- if (w_second_goban != NULL)
- GbSetPoint (w_second_goban, x, y, color);
-
- if ((setup = node->setup) != NULL)
- while (*setup != SG_EOS) {
- x = (*setup++ & 0x3f);
- y = (*setup++ & 0x3f);
-
- GbSetPoint (w_goban, x, y, GbEmptyPoint);
- if (w_second_goban != NULL)
- GbSetPoint (w_second_goban, x, y, GbEmptyPoint);
- }
-
- break;
- }
-
- ShowTmpProperty (node);
- }
- }
-
- /*******************************************************************************************************
- */
-
- void HideTmpProperty (node)
- SG_NodePtr node;
- {
- SG_PropertyPtr property;
- String text;
- unsigned char *ptr;
- int x;
- int y;
- Arg arg;
-
- if (edit == True) {
- XtSetArg (arg, XtNstring, &text); XtGetValues (c_comment, &arg, 1);
-
- if (node != NULL) {
- property = SG_GetProperty (node, SG_Comment);
-
- if (property != NULL && strcmp (property->data.pvalue, text) != 0) {
- SG_strcpy (&property->data.pvalue, text, '\0');
- modified = True;
- }
-
- else if (strcmp (text, "") != 0 && property == NULL) {
- SG_MakeProperty (node, SG_Comment, text);
- modified = True;
- }
- }
- }
-
- if (node != NULL) {
- property = node->property;
-
- while (property != NULL) {
- switch (property->id) {
-
- case SG_Comment : XtSetArg (arg, XtNstring, (XtArgVal) ""); XtSetValues (c_comment , &arg, 1); break;
- case SG_nodeName : XtSetArg (arg, XtNtitle , (XtArgVal) ""); XtSetValues (c_toplevel, &arg, 1); break;
- case SG_GameName :
- XtSetArg (arg, XtNtitle , (XtArgVal) ApplicationName); XtSetValues (w_toplevel, &arg, 1); break;
-
- case SG_Marked :
- case SG_Letters :
- if ((ptr = property->data.pvalue) != NULL) {
-
- while (*ptr != SG_EOS) {
- x = (*ptr++ & 0x3f);
- y = (*ptr++ & 0x3f);
-
- if (x != 0 || y != 0) {
- GbSetMark (w_goban, x, y, 0, 0);
- if (w_second_goban != NULL)
- GbSetMark (w_second_goban, x, y, 0, 0);
- }
- }
- }
- break;
- }
-
- property = property->next;
- }
-
- switch (node->type) {
-
- case SG_MoveType :
- while (node->left != NULL)
- node = node->left;
-
- while (node != NULL) {
- if (node->type == SG_MoveType) {
- GbSetMark (w_goban, node->x, node->y, 0, 0);
-
- if (w_second_goban != NULL)
- GbSetMark (w_second_goban, node->x, node->y, 0, 0);
- }
-
- node = node->right;
- }
-
- break;
- }
- }
- }
-
- /*******************************************************************************************************
- */
-
- void HideProperty (node)
- SG_NodePtr node;
- {
- Arg args[5];
- unsigned char *setup;
- int color;
- int x;
- int y;
- SG_PropertyPtr property;
-
- if (node != NULL) {
- property = node->property;
-
- while (property != NULL) {
- switch (property->id) {
-
- case SG_unVieW :
- XtSetArg (args[0], XtNviewTop , (Position) ((property->data.ivalue >> 24)));
- XtSetArg (args[1], XtNviewLeft , (Position) ((property->data.ivalue >> 16) & 0xff));
- XtSetArg (args[2], XtNviewBottom, (Position) ((property->data.ivalue >> 8) & 0xff));
- XtSetArg (args[3], XtNviewRight , (Position) ((property->data.ivalue ) & 0xff));
-
- XtSetValues (w_goban, args, 4);
- if (w_second_goban != NULL)
- XtSetValues (w_second_goban, args, 4);
- break;
- }
-
- property = property->next;
- }
-
- switch (node->type) {
-
- case SG_EventType :
- XtSetArg (args[0], XtNgameSize , 19);
- XtSetArg (args[1], XtNviewTop , 19);
- XtSetArg (args[2], XtNviewLeft , 1 );
- XtSetArg (args[3], XtNviewBottom, 1 );
- XtSetArg (args[4], XtNviewRight , 19);
-
- XtSetValues (w_goban, args, 5);
- if (w_second_goban != NULL)
- XtSetValues (w_second_goban, args, 5);
-
- case SG_DiagramType :
-
- if ((setup = node->setup) != NULL)
- while (*setup != SG_EOS) {
- color = (*setup & 0xc0);
- x = (*setup++ & 0x3f);
- y = (*setup++ & 0x3f);
-
- switch (color) {
- case SG_SETB :
- case SG_SETW : GbSetPoint (w_goban, x, y, GbEmptyPoint); break;
- case SG_SETEB : GbSetPoint (w_goban, x, y, GbBlackStone); break;
- case SG_SETEW : GbSetPoint (w_goban, x, y, GbWhiteStone); break;
- }
-
- if (w_second_goban != NULL)
- switch (color) {
- case SG_SETB :
- case SG_SETW : GbSetPoint (w_second_goban, x, y, GbEmptyPoint); break;
- case SG_SETEB : GbSetPoint (w_second_goban, x, y, GbBlackStone); break;
- case SG_SETEW : GbSetPoint (w_second_goban, x, y, GbWhiteStone); break;
- }
- }
- break;
-
- case SG_MoveType :
- x = node->x;
- y = node->y;
-
- GbSetPoint (w_goban, x, y, GbEmptyPoint);
- if (w_second_goban != NULL)
- GbSetPoint (w_second_goban, x, y, GbEmptyPoint);
-
- if ((setup = node->setup) != NULL) {
- color = (int) ((node->color == SG_BlackStone) ? GbWhiteStone : GbBlackStone);
-
- while (*setup != SG_EOS) {
- x = (*setup++ & 0x3f);
- y = (*setup++ & 0x3f);
-
- GbSetPoint (w_goban, x, y, color);
- if (w_second_goban != NULL)
- GbSetPoint (w_second_goban, x, y, color);
- }
- }
-
- break;
- }
-
- HideTmpProperty (node);
- }
- }
-
- /*******************************************************************************************************
- */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'game.c'
- then
- echo shar: will not over-write existing file "'game.c'"
- else
- cat << \SHAR_EOF > 'game.c'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <signal.h>
-
- /*
- * RESIGN
- * TERMINAISONS ...
- */
-
- #include <X11/Intrinsic.h>
-
- #include "xgoban.h"
-
- static FILE *to_black;
- static FILE *from_black;
- static FILE *to_white;
- static FILE *from_white;
-
- static int white_pid = -1;
- static int black_pid = -1;
-
- /*******************************************************************************************************
- */
-
- void signalMove (node)
- SG_NodePtr node;
- {
- int x = node->x;
- int y = node->y;
- Player player = (node->player == SG_BlackStone) ? black_player : white_player;
- FILE *to_file = (node->player == SG_BlackStone) ? to_black : to_white;
-
- switch (player) {
- case Wally :
- if (x == 0 && y == 0)
- (void) fprintf (to_file, "pass\n");
- else
- (void) fprintf (to_file, "%c%d\n", 'a' + ((x > 8) ? x : x - 1), 20 - y);
-
- (void) fflush (to_file);
- break;
-
- case Gnugo :
- if (x == 0 && y == 0)
- (void) fprintf (to_file, "pass\n");
- else
- (void) fprintf (to_file, "%c%d\n", 'A' + ((x > 8) ? x : x - 1), y);
-
- (void) fflush (to_file);
- break;
-
- case Human :
- if (w_second_toplevel != NULL && beep >= -100)
- if (second_player == node->player)
- XBell (XtDisplay (w_second_goban), beep);
- else
- XBell (XtDisplay (w_goban) , beep);
- break;
- }
- }
-
- static void receive_data (file)
- FILE *file;
- {
- char buffer[256];
- char *pat;
- int x = -1;
- int y = -1;
- SG_NodePtr node;
-
- if (current_mode == PlayMode) {
- if (fgets (buffer, 256, file) == NULL)
- return;
-
- switch (current_node->player == SG_BlackStone ? black_player : white_player) {
- case Wally :
- if ((pat = strstr (buffer, "Wally moves to")) != NULL) {
- sscanf (pat + 16, "%d", &y);
- x = *(pat + 15) - 'a' + 1;
- x = x > 8 ? x - 1 : x;
- y = 20 - y;
- }
- else if ((pat = strstr (buffer, "Wally passes")) != NULL) {
- x = 0;
- y = 0;
- }
- break;
-
- case Gnugo :
- if ((pat = strstr (buffer, "my move: ")) != NULL) {
- x = *(pat + 9) - 'A' + 1;
- x = x > 8 ? x - 1 : x;
- sscanf (pat + 10, "%d", &y);
- }
- break;
- }
-
- if (x != -1 && y != -1) {
-
- HideTmpProperty (current_node);
-
- node = SG_MakeNode (current_node, SG_Move);
- node->x = x;
- node->y = y;
- node->color = current_node->player;
-
- Play (node);
-
- modified = True;
- current_node = node;
-
- ShowProperty (current_node);
- RedisplayBoard ();
-
- if (x == 0 && y == 0)
- switch (node->player) {
- case SG_BlackStone : PopupDialog (w_goban, NULL, BlackPassDialog); break;
- case SG_WhiteStone : PopupDialog (w_goban, NULL, WhitePassDialog); break;
- }
-
- signalMove (node);
-
- if (beep >= -100)
- XBell (XtDisplay (w_goban), beep);
- }
- }
- }
-
- void startGame (app_context)
- XtAppContext app_context;
- {
- int from_pipe [2];
- int to_pipe[2];
- char *argv[10];
- int argc = 0;
-
- /*
- * Start black player program
- */
-
- if (black_player != Human) {
- pipe (from_pipe);
- pipe (to_pipe );
-
- if ((black_pid = fork ()) == 0) {
- fcntl(from_pipe[0], F_SETFL, O_NDELAY);
-
- close (0); dup (to_pipe [0]);
- close (1); dup (from_pipe[1]);
-
- close (to_pipe [0]);
- close (to_pipe [1]);
- close (from_pipe[0]);
- close (from_pipe[1]);
-
- switch (black_player) {
- case Wally :
- argv[argc++] = "wally";
- argv[argc++] = "\0\0\0"; sprintf (argv[argc - 1], "%d", board_size);
- if (handicap == 0) argv[argc++] = "-even";
- argv[argc++] = NULL;
-
- if (execvp ("wally", argv) == -1)
- { fprintf (stderr, "XGoban : can't exec wally\n"); stopGame (); exit (1); }
- break;
-
- case Gnugo :
- if (execlp ("gnugo", "gnugo", (char *) NULL) == -1)
- { fprintf (stderr, "XGoban : can't exec gnugo\n"); stopGame (); exit (1); }
- break;
-
- case Human : break;
- }
- }
-
- if (black_pid == -1)
- { fprintf (stderr, "XGoban : fork failed \n"); stopGame (); exit (1); }
-
- /*
- * XGoban : install pipe with black player
- */
-
- else {
- close (to_pipe [0]);
- close (from_pipe[1]);
-
- from_black = fdopen (from_pipe[0], "r");
- to_black = fdopen (to_pipe [1], "w");
-
- setbuf (from_black, (char *) NULL);
- setbuf (to_black , (char *) NULL);
-
- XtAppAddInput (app_context, fileno (from_black), (XtPointer) XtInputReadMask,
- (XtInputCallbackProc) receive_data, (XtPointer) from_black);
-
- switch (black_player) {
- case Wally : break;
- case Gnugo :
- (void) fprintf (to_black, "\n%d\nw\n", handicap);
- (void) fflush (to_black);
- break;
- case Human : break;
- }
- }
- }
-
- /*
- * Start white player program
- */
-
- if (white_player != Human) {
- pipe (from_pipe);
- pipe (to_pipe );
-
- if ((white_pid = fork ()) == 0) {
- fcntl(from_pipe[0], F_SETFL, O_NDELAY);
-
- close (0); dup (to_pipe [0]);
- close (1); dup (from_pipe[1]);
-
- close (to_pipe [0]);
- close (to_pipe [1]);
- close (from_pipe[0]);
- close (from_pipe[1]);
-
- switch (white_player) {
- case Gnugo :
- if (execlp ("gnugo", "gnugo", (char *) NULL) == -1)
- { fprintf (stderr, "XGoban : can't exec wally\n"); stopGame (); exit (1); }
- break;
- case Wally : break;
- case Human : break;
- }
- }
-
- if (white_pid == -1)
- { fprintf (stderr, "XGoban : fork failed \n"); stopGame (); exit (1); }
-
- /*
- * XGoban : install pipe with white player
- */
-
- close (to_pipe [0]);
- close (from_pipe[1]);
-
- from_white = fdopen (from_pipe[0], "r");
- to_white = fdopen (to_pipe [1], "w");
-
- setbuf (from_white, (char *) NULL);
- setbuf (to_white , (char *) NULL);
-
- XtAppAddInput (app_context, fileno (from_white), (XtPointer) XtInputReadMask,
- (XtInputCallbackProc) receive_data, (XtPointer) from_white);
-
- switch (white_player) {
- case Wally : break;
- case Human : break;
- case Gnugo :
- (void) fprintf (to_white, "\n%d\nb\n", handicap);
- (void) fflush (to_white);
- break;
- }
- }
- }
-
- void stopGame ()
- {
- if (black_pid != -1) (void) kill (black_pid, SIGKILL);
- if (white_pid != -1) (void) kill (white_pid, SIGKILL);
-
- current_mode = EditMode;
- }
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'blackstone.bm'
- then
- echo shar: will not over-write existing file "'blackstone.bm'"
- else
- cat << \SHAR_EOF > 'blackstone.bm'
- #define blackstone_width 16
- #define blackstone_height 16
- #define blackstone_x_hot 7
- #define blackstone_y_hot 8
- static char blackstone_bits[] = {
- 0xc0, 0x03, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xef, 0xfe, 0x77, 0xfe, 0x7b,
- 0xfc, 0x3c, 0xf8, 0x1f, 0xf0, 0x0f, 0xc0, 0x03};
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'graystone.bm'
- then
- echo shar: will not over-write existing file "'graystone.bm'"
- else
- cat << \SHAR_EOF > 'graystone.bm'
- #define graystone_width 16
- #define graystone_height 16
- #define graystone_x_hot 7
- #define graystone_y_hot 8
- static char graystone_bits[] = {
- 0xc0, 0x03, 0xb0, 0x0e, 0x58, 0x15, 0xac, 0x2a, 0x56, 0x55, 0xaa, 0x6a,
- 0x55, 0xd5, 0xab, 0xaa, 0x55, 0xd5, 0xab, 0xba, 0x56, 0x5d, 0xaa, 0x6e,
- 0x54, 0x37, 0xa8, 0x1a, 0x70, 0x0d, 0xc0, 0x03};
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'stonemask.bm'
- then
- echo shar: will not over-write existing file "'stonemask.bm'"
- else
- cat << \SHAR_EOF > 'stonemask.bm'
- #define stonemask_width 16
- #define stonemask_height 16
- #define stonemask_x_hot 7
- #define stonemask_y_hot 8
- static char stonemask_bits[] = {
- 0xc0, 0x03, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f,
- 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xc0, 0x03};
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'whitestone.bm'
- then
- echo shar: will not over-write existing file "'whitestone.bm'"
- else
- cat << \SHAR_EOF > 'whitestone.bm'
- #define whitestone_width 16
- #define whitestone_height 16
- #define whitestone_x_hot 7
- #define whitestone_y_hot 8
- static char whitestone_bits[] = {
- 0xc0, 0x03, 0x30, 0x0c, 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x02, 0x40,
- 0x01, 0x80, 0x01, 0x80, 0x01, 0x90, 0x01, 0x90, 0x02, 0x48, 0x02, 0x44,
- 0x04, 0x23, 0x08, 0x10, 0x30, 0x0c, 0xc0, 0x03};
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'icon.bm'
- then
- echo shar: will not over-write existing file "'icon.bm'"
- else
- cat << \SHAR_EOF > 'icon.bm'
- #define icon_width 82
- #define icon_height 82
- static char icon_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01,
- 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04,
- 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40,
- 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00,
- 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01,
- 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04,
- 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10,
- 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00,
- 0x20, 0x00, 0x01, 0x04, 0x10, 0xf0, 0x01, 0x01, 0x04, 0x10, 0x00, 0x20,
- 0x00, 0x01, 0x04, 0x10, 0xf8, 0x03, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00,
- 0x01, 0x04, 0x10, 0xfc, 0x07, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01,
- 0x04, 0x10, 0xfc, 0x07, 0x01, 0x04, 0x10, 0x00, 0xf8, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10,
- 0xfc, 0x06, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x7c,
- 0x07, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0xf8, 0x03,
- 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0xf0, 0x01, 0x01,
- 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04,
- 0x10, 0x00, 0x20, 0xc0, 0x07, 0x1f, 0x7c, 0xf0, 0x01, 0x01, 0x04, 0x10,
- 0x00, 0x20, 0x20, 0x88, 0x20, 0x82, 0xf8, 0x03, 0x01, 0x04, 0x10, 0x00,
- 0x20, 0x10, 0x50, 0x40, 0x01, 0xfd, 0x07, 0x01, 0x04, 0x10, 0x00, 0x20,
- 0x10, 0x50, 0x40, 0x01, 0xfd, 0x07, 0x01, 0x04, 0x10, 0x00, 0xf8, 0x1f,
- 0x70, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x20, 0x10, 0x54,
- 0x50, 0x41, 0xfd, 0x06, 0x01, 0x04, 0x10, 0x00, 0x20, 0x10, 0x52, 0x48,
- 0x21, 0x7d, 0x07, 0x01, 0x04, 0x10, 0x00, 0x20, 0x20, 0x88, 0x20, 0x82,
- 0xf8, 0x03, 0x01, 0x04, 0x10, 0x00, 0x20, 0xc0, 0x07, 0x1f, 0x7c, 0xf0,
- 0x01, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00,
- 0x01, 0x04, 0x10, 0x00, 0x20, 0xc0, 0x07, 0x1f, 0x7c, 0xf0, 0xc1, 0x07,
- 0x04, 0x10, 0x00, 0x20, 0x20, 0x88, 0x3f, 0xfe, 0x08, 0xe2, 0x0f, 0x04,
- 0x10, 0x00, 0x20, 0x10, 0xd0, 0x7f, 0xff, 0x05, 0xf4, 0x1f, 0x04, 0x10,
- 0x00, 0x20, 0x10, 0xd0, 0x7f, 0xff, 0x05, 0xf4, 0x1f, 0x04, 0x10, 0x00,
- 0xf8, 0x1f, 0xf0, 0xff, 0xff, 0x07, 0xfc, 0xff, 0xff, 0x7f, 0x00, 0x20,
- 0x10, 0xd4, 0x6f, 0xbf, 0x05, 0xf5, 0x1b, 0x04, 0x10, 0x00, 0x20, 0x10,
- 0xd2, 0x77, 0xdf, 0x85, 0xf4, 0x1d, 0x04, 0x10, 0x00, 0x20, 0x20, 0x88,
- 0x3f, 0xfe, 0x08, 0xe2, 0x0f, 0x04, 0x10, 0x00, 0x20, 0xc0, 0x07, 0x1f,
- 0x7c, 0xf0, 0xc1, 0x07, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10,
- 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0xf0,
- 0x01, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x08, 0x02,
- 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x04, 0x04, 0x01,
- 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x04, 0x04, 0x01, 0x04,
- 0x10, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x07, 0xfc, 0xff, 0xff, 0x7f,
- 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x04, 0x05, 0x01, 0x04, 0x10, 0x00,
- 0x20, 0x00, 0x01, 0x04, 0x10, 0x84, 0x04, 0x01, 0x04, 0x10, 0x00, 0x20,
- 0x00, 0x01, 0x04, 0x10, 0x08, 0x02, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00,
- 0x01, 0x04, 0x10, 0xf0, 0x01, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01,
- 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x1f,
- 0x7c, 0x40, 0x00, 0x01, 0x1f, 0x10, 0x00, 0x20, 0x00, 0x81, 0x3f, 0xfe,
- 0x40, 0x00, 0x81, 0x3f, 0x10, 0x00, 0x20, 0x00, 0xc1, 0x7f, 0xff, 0x41,
- 0x00, 0xc1, 0x7f, 0x10, 0x00, 0x20, 0x00, 0xc1, 0x7f, 0xff, 0x41, 0x00,
- 0xc1, 0x7f, 0x10, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f, 0x00, 0x20, 0x00, 0xc1, 0x6f, 0xbf, 0x41, 0x00, 0xc1, 0x6f,
- 0x10, 0x00, 0x20, 0x00, 0xc1, 0x77, 0xdf, 0x41, 0x00, 0xc1, 0x77, 0x10,
- 0x00, 0x20, 0x00, 0x81, 0x3f, 0xfe, 0x40, 0x00, 0x81, 0x3f, 0x10, 0x00,
- 0x20, 0x00, 0x01, 0x1f, 0x7c, 0x40, 0x00, 0x01, 0x1f, 0x10, 0x00, 0x20,
- 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00,
- 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01,
- 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04,
- 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10,
- 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x7f, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00,
- 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01,
- 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04,
- 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10,
- 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00,
- 0x20, 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20,
- 0x00, 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00,
- 0x01, 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01,
- 0x04, 0x10, 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0xf8, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10,
- 0x40, 0x00, 0x01, 0x04, 0x10, 0x00, 0x20, 0x00, 0x01, 0x04, 0x10, 0x40,
- 0x00, 0x01, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00};
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'Goban.h'
- then
- echo shar: will not over-write existing file "'Goban.h'"
- else
- cat << \SHAR_EOF > 'Goban.h'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #ifndef _Goban_h
- #define _Goban_h
-
- /* Resources:
-
- Name Class RepType Default Value
- ---- ----- ------- -------------
- autoRedisplay AutoRedisplay Boolean True
- background Background Pixel XtDefaultBackground
- blackStoneBackground Background Pixel black
- blackStoneBorder BorderColor Pixel black
- blackStoneForeground Foreground Pixel white
- border BorderColor Pixel XtDefaultForeground
- borderWidth BorderWidth Dimension 1
- cursor Cursor Integer GbGrayCursor
- destroyCallback Callback Pointer NULL
- displayCoordinates DisplayCoordinates Boolean True
- font Font XFontStruct* fixed
- foreground Foreground Pixel XtDefaultForeground
- gameSize Size Dimension 19
- height Height Dimension computed at create
- mappedWhenManaged MappedWhenManaged Boolean True
- pointSize Size Dimension 24
- sensitive Sensitive Boolean True
- viewBottom Position Position computed at create
- viewLeft Position Position computed at create
- viewRight Position Position computed at create
- viewTop Position Position computed at create
- whiteStoneBackground Background Pixel white
- whiteStoneBorder BorderColor Pixel black
- whiteStoneForeground Foreground Pixel black
- width Width Dimension computed at create
- x Position Position 0
- y Position Position 0
- */
-
- /* define any special resource names here that are not in <X11/StringDefs.h> */
-
- #define XtNautoRedisplay "autoRedisplay"
- #define XtNviewBottom "viewBottom"
-
- #ifndef XtNcursor
- #define XtNcursor "cursor"
- #endif
-
- #define XtNgameSize "gameSize"
- #define XtNviewLeft "viewLeft"
- #define XtNdisplayCoordinates "displayCoordinates"
- #define XtNpointSize "pointSize"
- #define XtNviewRight "viewRight"
- #define XtNviewTop "viewTop"
- #define XtNblackStoneBorder "blackStoneBorder"
- #define XtNblackStoneForeground "blackStoneForeground"
- #define XtNblackStoneBackground "blackStoneBackground"
- #define XtNwhiteStoneBorder "whiteStoneBorder"
- #define XtNwhiteStoneForeground "whiteStoneForeground"
- #define XtNwhiteStoneBackground "whiteStoneBackground"
-
- #define XtCAutoRedisplay "AutoRedisplay"
- #define XtCDisplayCoordinates "DisplayCoordinates"
- #define XtCSize "Size"
-
- #define XtEgbWhiteStone "white"
- #define XtEgbBlackStone "black"
- #define XtEgbGrayStone "gray"
-
- /* declare specific GobanWidget class and instance datatypes */
-
- typedef struct _GobanClassRec* GobanWidgetClass;
- typedef struct _GobanRec* GobanWidget;
-
- /* declare the class constant */
-
- extern WidgetClass gobanWidgetClass;
-
- /* cursors */
-
- #define GbCGrayStone 256
- #define GbCBlackStone 257
- #define GbCWhiteStone 258
-
- /* special marks */
-
- #define GbMSquareMark 1
- #define GbMTriangleMark 2
- #define GbMVCrossMark 3
- #define GbMDCrossMark 4
- #define GbMDiamondMark 5
-
- /* colors */
-
- typedef enum { GbEmptyPoint, GbBlackStone, GbWhiteStone } GbPointState;
-
- /* user functions */
-
- #define GbRemoveMark(w,x,y) GbSetMark (w, x, y, 0, 0)
-
- extern void GbRedisplayBoard ( /* Widget w */ );
- extern void GbClearBoard ( /* Widget w */ );
- extern void GbSetPoint ( /* Widget w, Position x, Position y, GbPointState color */ );
- extern void GbSetNum ( /* Widget w, Position x, Position y, int num */ );
- extern void GbSetMark ( /* Widget w, Position x, Position y, unsigned char mark1, unsigned char mark2 */ );
-
- extern Boolean GbGetPositionFromStone ( /* Widget w, Position *x, Position *y */ );
- extern Boolean GbGetStoneFromPosition ( /* Widget w, Position *x, Position *y */ );
-
- #endif /* _Goban_h */
-
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'GobanP.h'
- then
- echo shar: will not over-write existing file "'GobanP.h'"
- else
- cat << \SHAR_EOF > 'GobanP.h'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #ifndef _GobanP_h
- #define _GobanP_h
-
- #include "Goban.h"
-
- /* include superclass private header file */
- #include <X11/CoreP.h>
-
- /* define unique representation types not found in <X11/StringDefs.h> */
-
- #define XtRGobanResource "GobanResource"
-
- typedef struct {
- int empty;
- } GobanClassPart;
-
- typedef struct _GobanClassRec {
- CoreClassPart core_class;
- GobanClassPart goban_class;
- } GobanClassRec;
-
- extern GobanClassRec gobanClassRec;
-
- typedef struct {
- unsigned int free : 1;
- unsigned int black : 1;
- unsigned int mark1 : 8;
- unsigned int mark2 : 8;
- unsigned int num : 10;
- } PointState;
-
- typedef struct {
- /* resources */
-
- Boolean auto_redisplay;
- Position bottom;
- int cursor;
- XFontStruct *font;
- Pixel foreground;
- Dimension game_size;
- Position left;
- Boolean display_coordinates;
- Dimension point_size;
- Position right;
- Position top;
-
- /* private state */
-
- PointState points[20][20];
- Position x_offset;
- Position y_offset;
-
- Pixmap black_stone;
- Pixmap board;
- Pixmap gray_stone;
- Pixmap mouse_mask;
- Pixmap picture;
- Pixmap white_stone;
-
- GC background_gc;
- GC foreground_gc;
- GC black_fg_gc;
- GC black_bg_gc;
- GC black_bd_gc;
- GC white_fg_gc;
- GC white_bg_gc;
- GC white_bd_gc;
- GC copy_gc;
-
- Cursor black_cursor;
- Cursor gray_cursor;
- Cursor white_cursor;
- Cursor font_cursor;
-
- Pixel white_bg;
- Pixel white_fg;
- Pixel white_bd;
- Pixel black_bg;
- Pixel black_fg;
- Pixel black_bd;
- } GobanPart;
-
- typedef struct _GobanRec {
- CorePart core;
- GobanPart goban;
- } GobanRec;
-
- #define Min(x,y) ((x) > (y) ? (y) : (x))
- #define Max(x,y) ((x) > (y) ? (x) : (y))
-
- #endif /* _GobanP_h */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'sg.h'
- then
- echo shar: will not over-write existing file "'sg.h'"
- else
- cat << \SHAR_EOF > 'sg.h'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #ifndef _sg_h_
- #define _sg_h_
-
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <malloc.h>
-
- #define SG_Black 1 /* Done */
- #define SG_White 2 /* Done */
- #define SG_Comment 3 /* Done */
- #define SG_nodeName 4 /* Done */
- #define SG_nodeValue 5
- #define SG_CHeck 6
- #define SG_GoodBlack 7
- #define SG_GoodWhite 8
- #define SG_TEsuji 9
- #define SG_BadMove 10
- #define SG_BlackLeft 11 /* Done */
- #define SG_WhiteLeft 12 /* Done */
- #define SG_FiGure 13
- #define SG_AddBlack 14 /* Done */
- #define SG_AddWhite 15 /* Done */
- #define SG_AddEmpty 16 /* Done */
- #define SG_PLayer 17
- #define SG_GameName 18 /* Done */
- #define SG_GameComment 19 /* Done */
- #define SG_EVent 20 /* Done */
- #define SG_ROund 21 /* Done */
- #define SG_DaTe 22 /* Done */
- #define SG_PlaCe 23 /* Done */
- #define SG_PlayerBlack 24 /* Done */
- #define SG_PlayerWhite 25 /* Done */
- #define SG_REsult 26 /* Done */
- #define SG_USer 27 /* Done */
- #define SG_TiMe 28 /* Done */
- #define SG_SOurce 29 /* Done */
- #define SG_GaMe 30
- #define SG_SiZe 31
- #define SG_VieW 32 /* Done */
- #define SG_BlackSpec 33
- #define SG_WhiteSpec 34
- #define SG_EvaLuation 35
- #define SG_EXpected 36
- #define SG_SeLected 37
- #define SG_Marked 38
- #define SG_Letters 39
- #define SG_BlackRank 40 /* Done */
- #define SG_WhiteRank 41 /* Done */
- #define SG_HAndicap 42 /* Done */
- #define SG_KoMi 43 /* Done */
- #define SG_TerritoryBlack 44
- #define SG_TerritoryWhite 45
- #define SG_SeCure 46
- #define SG_ReGion 47
- #define SG_KO 48
- #define SG_Illegal 49
-
- #define SG_MaxID SG_Illegal
-
- #define SG_unVieW SG_Illegal + 1
- #define SG_ko SG_Illegal + 2
-
- typedef struct _SG_Property {
- int id;
-
- union {
- long ivalue;
- unsigned char *pvalue;
- } data;
-
- struct _SG_Property *next;
-
- } SG_Property, *SG_PropertyPtr;
-
- typedef struct _SG_Node {
-
- short type;
-
- short num;
- char color;
- char x;
- char y;
- char player;
-
- unsigned char *setup;
- SG_PropertyPtr property;
-
- struct _SG_Node *up;
- struct _SG_Node *down;
- struct _SG_Node *left;
- struct _SG_Node *right;
-
- } SG_Node, *SG_NodePtr;
-
- #define SG_NoType 0
- #define SG_EventType 1
- #define SG_MoveType 2
- #define SG_DiagramType 4
-
- #define SG_EmptyPoint 0
- #define SG_Border 1
- #define SG_WhiteStone 2
- #define SG_BlackStone 3
-
- #define SG_Event 0
- #define SG_Move 1
- #define SG_VariationMove 2
- #define SG_Diagram 3
- #define SG_VariationDiagram 4
-
- #define SG_SetupProperty 1
- #define SG_CommentProperty 2
- #define SG_GameNameProperty 3
-
- #define SG_EOS 0xff
-
- #define SG_SETMASK ((1 << 7) | (1 << 6))
- #define SG_SETB ((1 << 7) | (1 << 6))
- #define SG_SETW (1 << 7)
- #define SG_SETEB (1 << 6)
- #define SG_SETEW 0
- #define SG_SETE SG_SETEB
-
- #define SG_OK 0
- #define SG_PlaySuicide 1
- #define SG_PlayKo 2
- #define SG_PlayIllegal 3
-
- #define SG_EOFERR 1
- #define SG_NSTERR 2
- #define SG_NCLERR 3
- #define SG_NCTERR 4
- #define SG_NDGERR 5
-
- typedef struct {
- char *keyword;
- char *print;
- int id;
- int node_id;
- } SG_KWData;
-
- extern SG_KWData sg_keywords[];
-
- extern SG_NodePtr SG_MakeNode ();
- extern SG_PropertyPtr SG_GetProperty ();
- extern void SG_MakeProperty ();
- extern void SG_FreeNode ();
- extern SG_NodePtr SG_RemoveNode ();
- extern SG_NodePtr SG_ReadTree ();
- extern int SG_WriteTree ();
-
- extern void SG_strcat ();
- extern void SG_strcpy ();
-
- #endif /* _sg_h_ */
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'xgoban.h'
- then
- echo shar: will not over-write existing file "'xgoban.h'"
- else
- cat << \SHAR_EOF > 'xgoban.h'
- /****************************************************************************************************************
- *
- * Copyright (c) 1992 by Antoine Dumesnil de Maricourt. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful.
- * Use and copying of this software and preparation of derivative works
- * based upon this software are permitted, so long as the following
- * conditions are met:
- * o credit to the authors is acknowledged following current
- * academic behaviour
- * o no fees or compensation are charged for use, copies, or
- * access to this software
- * o this copyright notice is included intact.
- * This software is made available AS IS, and no warranty is made about
- * the software or its performance.
- *
- * Bug descriptions, use reports, comments or suggestions are welcome.
- * Send them to dumesnil@etca.fr or to:
- *
- * Antoine de Maricourt
- * ETCA CREA-SP
- * 16 bis, avenue Prieur de la Cote d'Or
- * 94114 Arcueil Cedex
- * France
- */
-
- #ifndef _xgoban_h_
- #define _xgoban_h_
-
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
-
- #include "sg.h"
- #include "Goban.h"
-
- typedef enum { Human, Wally, Gnugo } Player;
- typedef enum { EditMode, DiagramMode, SizeMode, ViewMode, PlayMode, MailMode } Mode;
-
- #define ApplicationName "XGoban"
-
- #define LoadDialog 2
- #define EditDialog 3
- #define SaveBeforeQuitDialog 5
- #define SaveAsAndQuitDialog 6
- #define ReallyQuitDialog 7
- #define SaveBeforeLoadDialog 8
- #define SaveAsAndLoadDialog 9
- #define SaveAsDialog 10
- #define CantSaveRetryDialog 11
- #define CantLoadRetryDialog 12
- #define HelpDialog 13
-
- #define PlayerNodeErrorWarning 14
- #define MemoryErrorDialog 15
- #define CantOpenFileDialog 16
- #define IllegalMoveDialog 17
- #define SuicideMoveDialog 18
- #define KoMoveDialog 19
- #define BadHandicapWarning 20
- #define RemainingStonesWarning 21
- #define ReadOnlyWarning 22
- #define DiagramBadNodeWarning 23
- #define SizeBadNodeWarning 24
- #define ReallyDeleteDialog 25
- #define PlayerMoveErrorWarning 26
- #define WallyWhitePlayWarning 27
- #define WallyBadSizeWarning 28
- #define WallyBadHandicapWarning 29
- #define StopGameDialog 30
- #define RemoveStonesDialog 31
- #define BlackPassDialog 32
- #define WhitePassDialog 33
- #define NodeNameDialog 34
- #define MailNoMoveDialog 35
- #define MailConfirmMoveDialog 36
- #define StopGameBeforeQuitDialog 37
-
- #define ReplaceNodeDialog 40
-
- #define BadHandicapMsg " Don't know how to place \n handicap stones \n for this size of board "
- #define RemainingStonesMsg " Don't know how to place \n remaining handicap stones "
- #define PlayerNodeErrorMsg " Player can be changed only \n at Event or Diagram node "
- #define PlayerMoveErrorMsg " Following move is already \n done : can't change Player "
- #define IllegalMoveMsg " This move is illegal "
- #define KoMoveMsg " You can't retake the \n ko now "
- #define SuicideMoveMsg " Suicide is not allowed "
- #define DiagramBadNodeMsg " Diagram can't be edited \n at Move node "
- #define SizeBadNodeMsg " Goban can be resized \n only at Event node "
- #define CantOpenFileMsg " Can't open file "
- #define WallyWhitePlayMsg " Wally only plays black "
- #define WallyBadSizeMsg " Wally plays on a 9x9, \n 13x13 or 19x19 board "
- #define WallyBadHandicapMsg " Wally plays with no or \n 9 handicap stones "
- #define BlackPassMsg " Black passes "
- #define WhitePassMsg " White passes "
-
- #define LoadFileMsg "Load file :"
- #define SaveFileMsg "Save file :"
- #define EditFileMsg "Edit file ?"
- #define ReplaceNodeMsg "Replace current node ?"
- #define ReallyQuitMsg "Really quit ?"
- #define ReallyDeleteMsg "Really delete current node ?"
- #define SaveFileBeforeMsg "Save file before ?"
- #define StopGameMsg "Stop current game ?"
- #define RemoveStonesMsg "Remove further moves ?"
- #define NodeNameMsg "Enter node name :"
- #define MailNoMoveMsg "No move done : really quit ?"
- #define MailConfirmMoveMsg "Confirm your move ?"
-
- #define YesLabel "Yes"
- #define NoLabel "No"
- #define CancelLabel "Cancel"
- #define SaveLabel "Save"
- #define LoadLabel "Load"
- #define EditLabel "Edit"
- #define QuitLabel "Quit"
- #define ReplaceLabel "Replace"
- #define OkLabel "Ok"
- #define DeleteLabel "Delete"
- #define RemoveLabel "Remove"
- #define StopLabel "Stop"
- #define ConfirmLabel "Confirm"
-
- #define ReadOnlyMsg " File is read-only "
- #define MemoryErrorMsg " Memory error "
-
- #define UsageString "\
- XGoban version 1.0\n\n\
- Usage : \n\
- xgoban [ <toolkit options> ... ] [ <options> ... ] [ <file> ] \n\n\
- where options include : \n\
- -help print out this message \n\
- -size <size> set goban size \n\
- -handicap <handicap> setup handicap stones \n\
- -path <path> path for smart-go files \n\
- -pointSize <pointSize> size of points in pixels\n\
- -silent turn off bell \n\
- -nonum turn off auto numbering \n\
- -versatile turn off strict moves \n\
- -black <blackPlayer> black player \n\
- -white <whitePlayer> white player \n\
- [-short | -s] short save mode \n\
- [-mail | -m] <filename> mail mode \n\
- \n"
-
- #define HelpString "\n\
- XGoban 1.0 by A. de Maricourt (c) 1992 \n\
- \n\
- \n\
- a : Append stones to diagram Bt1 : select variation \n\
- b : Black to play or move forward \n\
- d : select Diagram Bt2 : select diagram \n\
- e : Edit current file Bt3 : move backward \n\
- l : Load file \n\
- p : Pass S-Bt1 : make next move \n\
- q : Quit S-Bt3 : delete move \n\
- s : Save \n\
- v : View CS-Bt1 : make variation move \n\
- w : White to play CS-Bt2 : make variation diagram \n\
- z : siZe \n\
- > : move forward C-Bt1 : add letter \n\
- < : move backward C-Bt2 : add mark \n\
- } : next comment C-Bt3 : delete letter \n\
- { : previous comment \n\
- ] : next variation branch diagram editing : \n\
- [ : previous variation branch Bt1 : add black stone \n\
- ? : help Bt2 : add white stone \n\
- i : event Informations Bt3 : remove stone \n\
- CS-P : make variation pass Esc : diagram done \n\
- \n\
- Press any key or click to dismiss ... \n\
- \n"
-
- #define Max(x,y) ((x)>(y)?(x):(y))
- #define Min(x,y) ((x)>(y)?(y):(x))
- #define Abs(x) ((x)>0?(x):-(x))
-
- extern Widget w_toplevel;
- extern Widget w_goban;
- extern Widget w_menu;
- extern Widget c_toplevel;
- extern Widget c_comment;
- extern Widget w_second_toplevel;
- extern Widget w_second_form;
- extern Widget w_second_goban;
-
- extern SG_NodePtr tree;
- extern SG_NodePtr current_node;
- extern SG_NodePtr mail_node;
-
- extern Mode current_mode;
-
- extern Player black_player;
- extern Player white_player;
- extern int handicap;
- extern int board_size;
- extern int second_player;
-
- extern Boolean edit;
- extern Boolean modified;
- extern int beep;
- extern Boolean autonum;
- extern Boolean strict;
- extern Boolean short_print;
-
- extern char file_name[512];
- extern char mail_file_name[512];
- extern char *path;
-
- extern Boolean delete_confirm;
-
- extern void PopupDialog ();
- extern void makeDialogWindow ();
- extern void makeEventWindow ();
-
- extern void CenterWindow ();
- extern Boolean LoadFile ();
- extern Boolean SaveFile ();
- extern void ShowCursor ();
-
-
- extern void ShowTmpProperty ();
- extern void HideTmpProperty ();
- extern void ShowProperty ();
- extern void HideProperty ();
-
- extern void Edit ();
-
- extern int Play ();
- extern void Unplay ();
- extern void StartDiagram ();
- extern void AddStone ();
- extern unsigned char *EndDiagram ();
-
- extern void signalMove ();
- extern void stopGame ();
- extern void startGame ();
-
-
- #define RedisplayBoard() { GbRedisplayBoard (w_goban); if (w_second_goban != NULL) GbRedisplayBoard (w_second_goban); }
- #endif
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'Goban.doc'
- then
- echo shar: will not over-write existing file "'Goban.doc'"
- else
- cat << \SHAR_EOF > 'Goban.doc'
- Goban Widget
- ------------
-
- The Goban widget displays a full or partial go board within a rectangular area and
- allows an application to put or remove stones on it. The application can also draw
- numbers on stones, and marks (consisting of a one or two characters string) on stones
- or empty points. It has no knowledge of the game and thus doesn't remove dead stones
- if any (it is the application's responsability).
-
- For every position specification, the coordinate system uses an x axis going from left
- to right, and an y axis going from bottom to top.
-
- Resources
- ---------
-
- Name Class RepType Default Value
- ---- ----- ------- -------------
- autoRedisplay AutoRedisplay Boolean True
- background Background Pixel XtDefaultBackground
- blackStoneBackground Background Pixel black
- blackStoneBorder BorderColor Pixel black
- blackStoneForeground Foreground Pixel white
- border BorderColor Pixel XtDefaultForeground
- borderWidth BorderWidth Dimension 1
- cursor Cursor Integer GbGrayCursor
- destroyCallback Callback Pointer NULL
- displayCoordinates DisplayCoordinates Boolean True
- font Font XFontStruct* fixed
- foreground Foreground Pixel XtDefaultForeground
- gameSize Size Dimension 19
- height Height Dimension computed at create
- mappedWhenManaged MappedWhenManaged Boolean True
- pointSize Size Dimension 24
- sensitive Sensitive Boolean True
- viewBottom Position Position computed at create
- viewLeft Position Position computed at create
- viewRight Position Position computed at create
- viewTop Position Position computed at create
- whiteStoneBackground Background Pixel white
- whiteStoneBorder BorderColor Pixel black
- whiteStoneForeground Foreground Pixel black
- width Width Dimension computed at create
- x Position Position 0
- y Position Position 0
-
- autoRedisplay If this resource is True, then all changes on the widget (put or remove
- stones, put numbers or marks) will be immediatly flushed to the screen.
- This can be set to False in conjonction with GbRedisplay in order to
- improve the speed when displaying a position.
-
- background As usual.
- backgroundPixmap As usual.
-
- blackStoneBackground This color will be used to fill the black stones (usually black)
- blackStoneBorder This color will be used to draw a circle arround the black stones. This is
- usefull with white stones to delimit the circumference of the stone.
- blackStoneForeground This color will be used to draw marks and numbers on black stones.
-
- border As usual.
- borderWidth As usual.
-
-
- cursor The cursor that will be displayed : should be GbCGrayStone, GbCWhiteStone
- or GbCBlackStone or a valid cursorFont ID.
-
- destroyCallback As usual.
-
- font The font that will be used to put numbers and marks on the board and to
- display the coordinate marks.
-
- foreground As usual.
-
- gameSize The board size : board is always square and its size must range between
- 2 and 19.
-
- height As usual.
-
- mappedWhenManaged As usual.
-
- displayCoordinates If this resource is True, then the coordinate marks will be displayed
- around the board.
-
- pointSize The distance in pixels between points.
-
- sensitive As usual.
-
- viewBottom The bottom of the partial goban that is viewed. Must range between 1 and
- gameSize - 1.
-
- viewLeft The left of the partial goban that is viewed. Must range between 1 and
- gameSize - 1.
-
- viewRight The right of the partial goban that is viewed. Must range between
- viewLeft + 1 and gameSize.
-
- viewTop The top of the partial goban that is viewed. Must range between
- viewBottom + 1 and gameSize.
-
- width As usual.
-
- whiteStoneBackground This color will be used to fill the white stones (usually white)
- whiteStoneBorder This color will be used to draw a circle arround the white stones.
- whiteStoneForeground This color will be used to draw marks and numbers on white stones.
-
- x As usual.
- y As usual.
-
-
- Procedures provided for application
- -----------------------------------
-
- void GbRedisplayBoard (w)
- GobanWidget w;
-
- Redisplay the entire board <w> on the screen.
-
- void GbClearBoard (w)
- GobanWidget w;
-
- Remove all stones of the board <w> and call GbRedisplayBoard.
-
-
- typedef enum { GbEmptyPoint, GbBlackStone, GbWhiteStone, } GbPointState;
-
- void GbSetPoint (w, x, y, color)
- GobanWidget w;
- Position x;
- Position y;
- GbPointState color;
-
- Put a stone of color <color> at location <x><y> on the board <w>.
- If color is GbEmptyPoint, then the stone (if any) is removed from location <x><y>.
- All marks on this point are removed.
- If autoRedisplay if set to False the change will not be visible on the screen until
- the application calls GbRedisplay.
-
-
- void GbSetNum (w, x, y, num)
- GobanWidget w;
- Position x;
- Position y;
- unsigned int num;
-
- Draw the number <num> on the stone at location <x><y> on the board <w>.
- <num> must range between 0 and 999 and no number is displayed if there is no stone
- at this location.
- If <num> is equal to 0, all previous num (if any) is removed from stone.
- When the representation of <num> is to bigger than the stone size (according to font size)
- no number is displayed.
-
-
- void GbSetMark (w, x, y, mark1, mark2)
- GobanWidget w;
- Position x;
- Position y;
- unsigned char mark1;
- unsigned char mark2;
-
- Draw the two characters mark at location <x><y> on the board <w>.
- <x><y> may be an empty point.
- If <mark1> and <mark2> are equal to 0, the previous mark (if any) is removed from point.
- If <mark2> is equal to 0, only one character will be displayed.
- If <mark1> is equal to 0, <mark2> can be one of GbMSquareMark, GbMTriangleMark, GbMVCrossMark,
- GbMDCrossMark or GbMDiamondMark. In this case, geometric marks are drawn.
- When the representation of the mark is to bigger than the stone size (according to font size)
- no mark is displayed.
- GbRemoveMark(w,x,y) is defined as a macro call for GbSetMark(w,x,y,0,0).
-
-
- Boolean GbGetStoneFromPosition (w, x, y)
- GobanWidget w;
- Position *x;
- Position *y;
-
- Provide a way to know on what point occurs a mouse event.
- If the event occurs on a valid point on the board, GbGetStoneFromEvent returns TRUE,
- and <x> <y> variables are set to the coordinates of that point.
- If not, GbGetStoneFromEvent returns FALSE and <event> is unchanged.
-
-
- Boolean GbGetPositionFromStone (w, x, y)
- GobanWidget w;
- Position *x;
- Position *y;
-
- Provide a way to know what are the coordinates (in pixel) for the center of a given
- point. It works as GbGetStoneFromPosition.
- Those functions are not reverse of each other ...
-
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'xgoban.doc'
- then
- echo shar: will not over-write existing file "'xgoban.doc'"
- else
- cat << \SHAR_EOF > 'xgoban.doc'
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- NAME
- xgoban - X11 files editor for the game of go / interface to
- gnugo and wally
-
- SYNOPSIS
- xgoban [ -toolkitoptions ... ] [ -options ... ] [ _f_i_l_e_n_a_m_e ]
-
- DESCRIPTION
- _x_g_o_b_a_n works under 3 major modes : Edit, Play and Mail.
-
- In Edit mode, the _x_g_o_b_a_n program displays a go board and
- allows the user to edit go files. It can read and write
- files with the Smart-Go format. When started in Edit mode,
- _x_g_o_b_a_n shows 2 windows : one for the board and the other to
- display comments. The title of the comment window is set to
- the name of current node if there is one. The title of the
- board is set to the name of the current game.
-
- In Play mode, _x_g_o_b_a_n can be used to play against go programs
- (currently supported : wally and gnugo) or against human
- opponent. The game can also be saved with the Smart-Go for-
- mat. When started in Play mode, the program can switch to
- Edit mode and thus allows the user to edit the played game.
- There is no comment window in this mode.
-
- Mail mode is designed to be used in combination with the
- _m_a_i_l_g_o script from Adrian Mariano.
-
- OPTIONS
- _x_g_o_b_a_n accepts all of the standard toolkit command line
- options as well as the following :
-
- -size _s_i_z_e
- This option specifies the size of the goban : _s_i_z_e
- must range between 2 and 19. It can be used in Play
- or Edit mode. The default size is 19.
-
- -handicap _h_a_n_d_i_c_a_p
- In Play mode, this option specifies the number of
- handicap stones that are to be put on the goban
- before the game starts. Legal values for _h_a_n_d_i_c_a_p
- depend on the size of the board and on the playing
- program. Whitin Edit mode, a first node is created
- and handicap stones are put under the AddBlack pro-
- perty.
-
- -black _b_l_a_c_k_p_l_a_y_e_r
- This options indicates the name of the black player.
- _x_g_o_b_a_n is started within Play mode and _b_l_a_c_k_p_l_a_y_e_r
- is added on the root node under the PlayerBlack pro-
- perty. _x_g_o_b_a_n recognize 2 program names : gnugo and
- wally. When _b_l_a_c_k_p_l_a_y_e_r is one of them, an attempt
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 1
-
-
-
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- is made to run the corresponding program (which must
- be found using the current environment variable
- PATH).
-
- -white _w_h_i_t_e_p_l_a_y_e_r
- This option is the same as -black, but for the white
- player.
-
- -path _p_a_t_h
- This option specifies the path where files are
- searched before loading them. A _p_a_t_h _i_s _a _c_o_m_m_a
- _s_e_p_a_r_a_t_e_d _l_i_s_t _o_f _d_i_r_e_c_t_o_r_i_e_s.
-
- -pointSize _s_i_z_e
- This option specifies the size in pixels for a small
- square of the board.
-
- -nonumber
- This option turns off the automatic numbering facil-
- ity.
-
- -silent
- This option turns off the bell. -beep _v_o_l_u_m_e
- This option specifies the volume of the bell when it
- is not turned off. Legal values range between -100
- and 100. I am not sure it will work on all keyboards
- ... Default value is 0.
-
- -versatile
- This option turns off strong verification of the
- tree : see below. This also turns off the automatic
- numbering facility.
-
- -help
- Displays a list of allowed options. _x_g_o_b_a_n is not
- started.
-
- [ -mail | -m ] _m_a_i_l_f_i_l_e
- Start _x_g_o_b_a_n in Mail mode. A file should be speci-
- fied with _f_i_l_e_n_a_m_e argument. This file is read, and
- _x_g_o_b_a_n automatically moves to the end of the main
- variation. When you quit _x_g_o_b_a_n, the game tree will
- be saved to _m_a_i_l_f_i_l_e. The exit value will be 0 if a
- move has been made and 1 otherwise. This option has
- been designed to work with the _m_a_i_l_g_o script from
- Adrian Mariano (adrian@u.washington.edu). -m option
- is for compatibility with _m_g_t.
-
- [ -short | -s ]
- This option forces _x_g_o_b_a_n to save files in short
- mode : only uppercase letters of keywords are
- printed, and there is no carriage return. -s option
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 2
-
-
-
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- is for compatibility with _m_g_t.
-
- -stipple<x>
- These options set the backgroundPixmap ressource of
- the Goban widget to predefined gray pixmaps (<x>
- must be one of 1, 2 or 3). You may like it if you
- use a black and white display. This is an idea of
- Stephen Coffin.
-
- One of -white, -black option starts _x_g_o_b_a_n in Play mode.
- Default is Edit mode.
-
- OPERATIONS
- When used in Edit mode, _x_g_o_b_a_n allows the user to edit go
- files. Commands are entered form the keyboard or from the
- mouse. Most of the window that are poped down contain a Con-
- firm (or Yes) an a Cancel (or No) button. Escape key is
- associated with the Cancel button, while Return Key is asso-
- ciated with the Confirm button.
-
- When an action is not allowed (because the mode your are in)
- you will hear a beep. Of course you hear nothing if you
- turned the bell off.
-
- First are commands that can be used to only view a file :
-
- > Moves to next node along the tree and displays its
- properties.
-
- < Hides properties of current node and moves to previ-
- ous node along the tree.
-
- } Goes down along the tree until a commented node or a
- variation node is seen.
-
- { Goes up along the tree until a commented node or the
- top of the tree is seen.
-
- ] Goes down along the tree until a variation node or
- the bottom of the tree is seen.
-
- [ Goes up along the tree until a variation node or the
- top of the tree is seen.
-
- ? Pops down a short help window.
-
- q Exits from the program.
-
- l Loads a file.
-
- s Saves the current tree to a file.
-
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 3
-
-
-
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- i Pops down a window that contains some properties of
- the current event (GameName, PlayerWhite, WhiteRank,
- WhiteSpecies ... and GameComment) You can change
- these properties or just view them.
-
- A-Z When there are some variations, an uppercase letter
- is displayed on each point corresponding to each
- possible move. The A-Z keys can be used to select
- the corresponding node. See also Btn2 action
-
- Btn1 When there are variations and the mouse points at a
- marked point (with uppercase letter), selects the
- corresponding node. Otherwise it is the same as key
- `>'.
-
- Btn2 It can arise that not all variations can be marked
- with an uppercase letter : if a variation is a
- diagram (having AddBlack, AddWhite or AddEmpty pro-
- perty), if there is variations on the same level
- with differently colored move (Black and White), or
- if there is a pass move. In this case, the cursor
- will be gray. Pressing the middle button pops up a
- menu where all variations are listed. You can
- choose the one you want to display
-
- Btn3 Same as key `<'.
-
- Following commands can be used to change a tree :
-
- v Enters the View sub-mode and allows the user to
- select a partial view of the board. A VieW property
- is then attached to the node.
-
- z Enters the Size sub-mode and allows the user to set
- the size of the board. SiZe property can only be
- change at Event node (see below) and the board is
- cleared.
-
- w Set the PLayer property to white for the current
- node. The next move will be a white stone.
-
- b Set the PLayer property to black for the current
- node. The next move will a black stone.
-
- n Prompt a dialog to edit the name of current node.
-
- a If the current node is a diagram, Enters the Diagram
- sub-mode and allows the user to edit the diagram.
-
- Shift Btn1
- Adds a move after the current node. The new node is
- created with property White or Black according to
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 4
-
-
-
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- the color of the last move. The mouse must point on
- the intersection where you want to put the stone.
-
- Shift Btn3
- Deletes the current node and all its sub-nodes.
-
- Ctrl Shift Btn1
- Makes a variation move. The color is the same as
- the PLayer property of previous node. The mouse
- must point on the intersection where you want to put
- a the stone.
-
- Ctrl Shift P
- Makes a variation move which is a pass move. The
- color is the same as the PLayer property of previous
- node.
-
- Ctrl Shift Btn2
- Makes a variation diagram. It enters in the Diagram
- sub-mode (see below) to allow the user to put stones
- on the diagram.
-
- Ctrl Btn1
- Puts a letter (downcase) on the mouse pointed inter-
- section.
-
- Ctrl Btn2
- Puts a triangle mark on the mouse pointed intersec-
- tion.
-
- Ctrl Btn3
- Remove any letter or mark from the mouse pointed
- intersection.
-
- There are sub-modes of Edit mode that can be Diagram, View
- or Size. Whitin these sub-modes, actions are changed. The
- Diagram sub-mode is signaled by a `point' cursor, while the
- View and Size sub-modes are signalled by the `upper-left-
- corner' cursor.
-
- Escape
- Quit the Diagram, Size or View sub-mode.
-
- Btn1 Within Diagram sub-mode : puts a black stone on the
- mouse pointed intersection.
-
- Btn2 Within Diagram sub-mode : puts a white stone on the
- mouse pointed intersection.
-
- Btn3 Within Diagram sub-mode : removes any stone from the
- mouse pointed intersection.
-
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 5
-
-
-
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- Btn1 Press
- Within View or Size sub-mode : start draging a rec-
- tangle to select the view or the size.
-
- Btn1 Motion
- Within View or Size sub-mode : drags the rectangle.
-
- Btn1 Release
- Within View or Size sub-mode : stop draging the rec-
- tangle and add a VieW or SiZe property to the
- current node.
-
- GAME TREE
- Game trees that can be made are slightly different from
- Smart-Go format. I wanted them to be closer to a `real'
- game.
-
- Node are either of type Diagram (they have AddBlack,
- AddWhite or AddEmpty property) or of type Move (they have
- Black or White property). Only a Diagram can have the
- PLayer property (default is PLayer[B]), which can be set
- only if the diagram does not have a successor. A file is a
- collection of Event nodes, which are of type Diagram. A
- node can have one or more successors (in which case, succes-
- sors are variations). If a node has only one successor,
- that successor can only be of type Move. If a node is of
- type Move, the color of any successor can only be the oppo-
- site of its color. If a node is of type Diagram, the color
- of any successor is the same as the PLayer property of the
- diagram.
-
- However, I noticed that most of the avaible game record
- doesn't match these restrictions. _x_g_o_b_a_n can read such
- unrestricted files but not edit them and create new unres-
- tricted nodes. Thus I added a -versatile option that turns
- off strong verification for accepted colors of nodes. When
- you specify -versatile option, you can change the PLayer
- property even at Move nodes or at any node that already have
- a successor.
-
- RESOURCES
- Resources can be set via xrdb or in the .Xdefault file.
- Default resources are as follow :
-
- XGoban*size : 19
- XGoban*handicap : 0
- XGoban*path : "."
- XGoban*pointSize : 26
- XGoban*autonum : True
- XGoban*beep : True
- XGoban*versatile : False
-
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 6
-
-
-
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- You can change the board color if you want. Remember that
- the board background shouldn't be black : thus, on a black
- and white display the only valid background is white.
-
- XGoban*goban.background : tan1
- XGoban*goban.foreground : black
-
- But everything else can be black on a white background if
- you like it :
-
- XGoban*background : black
- XGoban*foreground : white
- XGoban*borderColor : white
-
- You can also control the geometry of windows :
-
- XGoban.geometry : 500x500+30+30
- XGoban.comment.geometry : 500x200+30+580
-
- You can change the translation table for the goban Widget
- (see xgoban.c for the default translation table). You must
- be carefull by doing this because of multiple modes. Some
- action work only in a specified mode, and you can bind them
- to the same event if they don't work in the same mode. But
- don't bind two actions working in the same mode with the
- same event ... you may have trouble. A good way to change
- the translation table is just to change the left part (name
- of events) and to leave the right part (action) as it is.
- To change the translation table see a doc on X Toolkit and
- modify your .Xdefaults accordly.
-
- EXAMPLES
- To read and edit the file 001_001.s :
- xgoban 001_001.s
- To play black against gnugo with 5 handicap stones :
- xgoban -handicap 5 -white gnugo
- To play white against wally :
- xgoban -black wally
- To make wally play against gnugo :
- xgoban -black wally -white gnugo
-
- BUGS
- When read, a file is supposed to be syntacticaly correct.
- This is normally the case, when you didn't create this file
- by hand ...
-
- File names are limited to 512 bytes.
-
- -pointSize option doesn't work with smaller size than 19x19.
- The board size is calculated as if it were a 19x19 board,
- and then the board size is changed whitin the same square.
-
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 7
-
-
-
-
-
-
- XGOBAN(6) GAMES AND DEMOS XGOBAN(6)
-
-
-
- Resign is not supported in Play mode, and you can't use the
- counting features of gnugo or wally.
-
- SEE ALSO
- _m_g_t from Greg Hale.
- _m_a_i_l_g_o from Adrian Mariano.
-
- _m_g_t, _m_a_i_l_g_o and game records are available at
- milton.u.washington.edu.
-
- AUTHORS
- Antoine Dumesnil de Maricourt (dumesnil@etca.fr)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sun Release 4.1 Last change: 15 May 1992 8
-
-
-
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'xgoban.man'
- then
- echo shar: will not over-write existing file "'xgoban.man'"
- else
- cat << \SHAR_EOF > 'xgoban.man'
- .TH XGOBAN 6 "15 May 1992"
- .SH NAME
- xgoban - X11 files editor for the game of go /
- interface to gnugo and wally
- .SH SYNOPSIS
- .B xgoban
- [
- .B \-toolkitoptions ...
- ]
- [
- .B \-options ...
- ]
- [ \fIfilename\fP ]
- .SH DESCRIPTION
- .PP
- \fIxgoban\fP works under 3 major modes : Edit, Play and Mail.
- .LP
- In Edit mode, the \fIxgoban\fP program displays a go board and allows
- the user to edit go files.
- It can read and write files with the Smart-Go format.
- When started in Edit mode, \fIxgoban\fP shows 2 windows : one for the
- board and the other to display comments.
- The title of the comment window is set to the name of current node if
- there is one.
- The title of the board is set to the name of the current game.
- .LP
- In Play mode, \fIxgoban\fP can be used to play against go
- programs (currently supported : wally and gnugo) or against human opponent.
- The game can also be saved with the Smart-Go format.
- When started in Play mode, the program can switch to Edit mode and thus
- allows the user to edit the played game.
- There is no comment window in this mode.
- .LP
- Mail mode is designed to be used in combination with the \fImailgo\fP
- script from Adrian Mariano.
- .SH OPTIONS
- \fIxgoban\fP accepts all of the standard toolkit command line options as
- well as the following :
- .TP 8
- .B \-size \fIsize\fP
- This option specifies the size of the goban : \fIsize\fP must range between
- 2 and 19. It can be used in Play or Edit mode. The default size is 19.
- .TP 8
- .B \-handicap \fIhandicap\fP
- In Play mode, this option specifies the number of handicap stones that
- are to be put on the goban before the game starts.
- Legal values for \fIhandicap\fP depend on the size of the board and on
- the playing program.
- Whitin Edit mode, a first node is created and handicap stones are put
- under the AddBlack property.
- .TP 8
- .B \-black \fIblackplayer\fP
- This options indicates the name of the black player. \fIxgoban\fP
- is started within Play mode and \fIblackplayer\fP is added on the root
- node under the PlayerBlack property.
- \fIxgoban\fP recognize 2 program names : gnugo and wally.
- When \fIblackplayer\fP is one of them, an attempt is made to run the
- corresponding program (which must be found using the current environment variable
- PATH).
- .TP 8
- .B \-white \fIwhiteplayer\fP
- This option is the same as -black, but for the white player.
- .TP 8
- .B \-path \fIpath\fP
- This option specifies the path where files are searched before loading them.
- A \fIpath\fp is a comma separated list of directories.
- .TP 8
- .B \-pointSize \fIsize\fP
- This option specifies the size in pixels for a small square of the board.
- .TP 8
- .B \-nonumber
- This option turns off the automatic numbering facility.
- .TP 8
- .B \-silent
- .br
- This option turns off the bell.
- .B \-beep \fIvolume\fP
- .br
- This option specifies the volume of the bell when it is not turned off.
- Legal values range between -100 and 100.
- I am not sure it will work on all keyboards ...
- Default value is 0.
- .TP 8
- .B \-versatile
- This option turns off strong verification of the tree : see below.
- This also turns off the automatic numbering facility.
- .TP 8
- .B \-help
- .br
- Displays a list of allowed options.
- \fIxgoban\fP is not started.
- .TP 8
- .B [ \-mail | \-m ] \fImailfile\fP
- Start \fIxgoban\fP in Mail mode. A file should be specified with
- \fIfilename\fP argument. This file is read, and \fIxgoban\fP automatically
- moves to the end of the main variation.
- When you quit \fIxgoban\fP, the game tree will be saved to
- \fImailfile\fP. The exit value will be 0 if a move has been made
- and 1 otherwise. This option has been designed to work with the
- \fImailgo\fP script from Adrian Mariano (adrian@u.washington.edu).
- \-m option is for compatibility with \fImgt\fP.
- .TP 8
- .B [ \-short | \-s ]
- This option forces \fIxgoban\fP to save files in short mode : only
- uppercase letters of keywords are printed, and there is no carriage
- return. \-s option is for compatibility with \fImgt\fP.
- .TP 8
- .B -stipple<x>
- These options set the backgroundPixmap ressource of the Goban widget
- to predefined gray pixmaps (<x> must be one of 1, 2 or 3).
- You may like it if you use a black and white
- display. This is an idea of Stephen Coffin.
- .LP
- One of \-white, \-black option starts \fIxgoban\fP in Play mode.
- Default is Edit mode.
- .SH OPERATIONS
- .B
- When used in Edit mode, \fIxgoban\fP allows the user to edit go files.
- Commands are entered form the keyboard or from the mouse.
- Most of the window that are poped down contain a Confirm (or Yes) an a
- Cancel (or No) button.
- Escape key is associated with the Cancel button, while Return
- Key is associated with the Confirm button.
- .LP
- When an action is not allowed (because the mode your are in)
- you will hear a beep. Of course you hear nothing if you turned
- the bell off.
- .LP
- First are commands that can be used to only view a file :
- .LP
- .TP 8
- >
- Moves to next node along the tree and displays its properties.
- .LP
- .TP 8
- <
- Hides properties of current node and moves to previous node
- along the tree.
- .LP
- .TP 8
- }
- Goes down along the tree until a commented node or a variation node
- is seen.
- .LP
- .TP 8
- {
- Goes up along the tree until a commented node or the top of the tree
- is seen.
- .LP
- .TP 8
- ]
- Goes down along the tree until a variation node or the bottom of the
- tree is seen.
- .LP
- .TP 8
- [
- Goes up along the tree until a variation node or the top of the tree
- is seen.
- .LP
- .TP 8
- ?
- Pops down a short help window.
- .LP
- .TP 8
- q
- Exits from the program.
- .LP
- .TP 8
- l
- Loads a file.
- .LP
- .TP 8
- s
- Saves the current tree to a file.
- .LP
- .TP 8
- i
- Pops down a window that contains some properties of the current event
- (GameName, PlayerWhite, WhiteRank, WhiteSpecies ... and GameComment)
- You can change these properties or just view them.
- .LP
- .TP 8
- A-Z
- When there are some variations, an uppercase letter is displayed on each
- point corresponding to each possible move.
- The A-Z keys can be used to select the corresponding node.
- See also Btn2 action
- .LP
- .TP 8
- Btn1
- When there are variations and the mouse points at a marked point (with
- uppercase letter), selects the corresponding node.
- Otherwise it is the same as key `>'.
- .LP
- .TP 8
- Btn2
- It can arise that not all variations can be marked with an uppercase
- letter : if a variation is a diagram (having AddBlack, AddWhite or AddEmpty
- property), if there is variations on the same level
- with differently colored move (Black and White), or if there is a pass move.
- In this case, the cursor will be gray.
- Pressing the middle button pops up a menu where all variations are listed.
- You can choose the one you want to display
- .LP
- .TP 8
- Btn3
- Same as key `<'.
- .LP
- Following commands can be used to change a tree :
- .LP
- .TP 8
- v
- Enters the View sub-mode and allows the user to select a partial view of the
- board. A VieW property is then attached to the node.
- .LP
- .TP 8
- z
- Enters the Size sub-mode and allows the user to set the size of the board.
- SiZe property can only be change at Event node (see below) and the board
- is cleared.
- .LP
- .TP 8
- w
- Set the PLayer property to white for the current node.
- The next move will be a white stone.
- .LP
- .TP 8
- b
- Set the PLayer property to black for the current node.
- The next move will a black stone.
- .LP
- .TP 8
- n
- Prompt a dialog to edit the name of current node.
- .LP
- .TP 8
- a
- If the current node is a diagram,
- Enters the Diagram sub-mode and allows the user to edit the diagram.
- .LP
- .TP 8
- Shift Btn1
- Adds a move after the current node.
- The new node is created with property
- White or Black according to the color of the last move.
- The mouse must point on the intersection where you want to put the stone.
- .LP
- .TP 8
- Shift Btn3
- Deletes the current node and all its sub-nodes.
- .LP
- .TP 8
- Ctrl Shift Btn1
- Makes a variation move.
- The color is the same as the PLayer property of previous node.
- The mouse must point on the intersection where you want to put a the stone.
- .LP
- .TP 8
- Ctrl Shift P
- Makes a variation move which is a pass move.
- The color is the same as the PLayer property of previous node.
- .LP
- .TP 8
- Ctrl Shift Btn2
- Makes a variation diagram.
- It enters in the Diagram sub-mode (see below) to allow the user to put stones on
- the diagram.
- .LP
- .TP 8
- Ctrl Btn1
- Puts a letter (downcase) on the mouse pointed intersection.
- .LP
- .TP 8
- Ctrl Btn2
- Puts a triangle mark on the mouse pointed intersection.
- .LP
- .TP 8
- Ctrl Btn3
- Remove any letter or mark from the mouse pointed intersection.
- .LP
- There are sub-modes of Edit mode that can be Diagram, View or Size.
- Whitin these sub-modes, actions are changed.
- The Diagram sub-mode is signaled by a `point' cursor, while the View and
- Size sub-modes are signalled by the `upper-left-corner' cursor.
- .LP
- .TP 8
- Escape
- .br
- Quit the Diagram, Size or View sub-mode.
- .LP
- .TP 8
- Btn1
- Within Diagram sub-mode : puts a black stone on the mouse pointed intersection.
- .LP
- .TP 8
- Btn2
- Within Diagram sub-mode : puts a white stone on the mouse pointed intersection.
- .LP
- .TP 8
- Btn3
- Within Diagram sub-mode : removes any stone from the mouse pointed intersection.
- .LP
- .TP 8
- Btn1 Press
- Within View or Size sub-mode : start draging a rectangle to select the view
- or the size.
- .LP
- .TP 8
- Btn1 Motion
- Within View or Size sub-mode : drags the rectangle.
- .LP
- .TP 8
- Btn1 Release
- Within View or Size sub-mode : stop draging the rectangle and add a VieW or SiZe
- property to the current node.
- .SH GAME TREE
- Game trees that can be made are slightly different from Smart-Go format.
- I wanted them to be closer to a `real' game.
- .LP
- Node are either of type Diagram (they have AddBlack, AddWhite or AddEmpty property)
- or of type Move (they have Black or White property).
- Only a Diagram can have the PLayer property (default is PLayer[B]), which
- can be set only if the diagram does not have a successor.
- A file is a collection of Event nodes, which are of type Diagram.
- A node can have one or more successors (in which case, successors are variations).
- If a node has only one successor, that successor can only be of type Move.
- If a node is of type Move, the color of any successor can only be the opposite
- of its color.
- If a node is of type Diagram, the color of any successor is the same as the PLayer
- property of the diagram.
- .LP
- However, I noticed that most of the avaible game record doesn't match these restrictions.
- \fIxgoban\fP can read such unrestricted files but not edit them and create new
- unrestricted nodes.
- Thus I added a \-versatile option that turns off strong verification for accepted colors
- of nodes.
- When you specify \-versatile option, you can change the PLayer property even at Move nodes
- or at any node that already have a successor.
- .SH RESOURCES
- Resources can be set via xrdb or in the .Xdefault file.
- Default resources are as follow :
- .sp
- .nf
- .ta .5i
- XGoban*size : 19
- XGoban*handicap : 0
- XGoban*path : "."
- XGoban*pointSize : 26
- XGoban*autonum : True
- XGoban*beep : True
- XGoban*versatile : False
- .fi
- .LP
- You can change the board color if you want. Remember that the board background
- shouldn't be black : thus, on a black and white display the only valid background
- is white.
- .sp
- .nf
- .ta .5i
- XGoban*goban.background : tan1
- XGoban*goban.foreground : black
- .fi
- .LP
- But everything else can be black on a white background if you like it :
- .sp
- .nf
- .ta .5i
- XGoban*background : black
- XGoban*foreground : white
- XGoban*borderColor : white
- .fi
- .LP
- You can also control the geometry of windows :
- .sp
- .nf
- .ta .5i
- XGoban.geometry : 500x500+30+30
- XGoban.comment.geometry : 500x200+30+580
- .fi
- .LP
- You can change the translation table for the goban Widget (see xgoban.c for the
- default translation table). You must be carefull by doing this because of multiple
- modes. Some action work only in a specified mode, and you can bind them to the same
- event if they don't work in the same mode. But don't bind two actions working in the
- same mode with the same event ... you may have trouble.
- A good way to change the translation table is just to change the left part (name of
- events) and to leave the right part (action) as it is.
- To change the translation table see a doc on X Toolkit and modify your .Xdefaults
- accordly.
- .SH EXAMPLES
- .PD 0
- .TP 5
- To read and edit the file 001_001.s :
- .B xgoban 001_001.s
- .TP 5
- To play black against gnugo with 5 handicap stones :
- .B xgoban -handicap 5 -white gnugo
- .TP 5
- To play white against wally :
- .B xgoban -black wally
- .TP 5
- To make wally play against gnugo :
- .B xgoban -black wally -white gnugo
- .PD
- .SH BUGS
- .LP
- When read, a file is supposed to be syntacticaly correct.
- This is normally the case, when you didn't create this file by hand ...
- .LP
- File names are limited to 512 bytes.
- .LP
- \-pointSize option doesn't work with smaller size than 19x19.
- The board size is calculated as if it were a 19x19 board, and
- then the board size is changed whitin the same square.
- .LP
- Resign is not supported in Play mode, and you can't use the counting
- features of gnugo or wally.
- .LP
- Once you edit a file, you can't start editing another one without quiting
- \fIxgoban\fP. You can also delete all top nodes but beware from erasing you
- previous file with the save command.
- .SH SEE ALSO
- \fImgt\fP from Greg Hale.
- .br
- \fImailgo\fP from Adrian Mariano.
- .LP
- \fImgt\fP, \fImailgo\fP and game records
- are available at milton.u.washington.edu.
- .SH AUTHORS
- Antoine Dumesnil de Maricourt (dumesnil@etca.fr)
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'xgoban.6'
- then
- echo shar: will not over-write existing file "'xgoban.6'"
- else
- cat << \SHAR_EOF > 'xgoban.6'
- .TH XGOBAN 6 "15 May 1992"
- .SH NAME
- xgoban - X11 files editor for the game of go /
- interface to gnugo and wally
- .SH SYNOPSIS
- .B xgoban
- [
- .B \-toolkitoptions ...
- ]
- [
- .B \-options ...
- ]
- [ \fIfilename\fP ]
- .SH DESCRIPTION
- .PP
- \fIxgoban\fP works under 3 major modes : Edit, Play and Mail.
- .LP
- In Edit mode, the \fIxgoban\fP program displays a go board and allows
- the user to edit go files.
- It can read and write files with the Smart-Go format.
- When started in Edit mode, \fIxgoban\fP shows 2 windows : one for the
- board and the other to display comments.
- The title of the comment window is set to the name of current node if
- there is one.
- The title of the board is set to the name of the current game.
- .LP
- In Play mode, \fIxgoban\fP can be used to play against go
- programs (currently supported : wally and gnugo) or against human opponent.
- The game can also be saved with the Smart-Go format.
- When started in Play mode, the program can switch to Edit mode and thus
- allows the user to edit the played game.
- There is no comment window in this mode.
- .LP
- Mail mode is designed to be used in combination with the \fImailgo\fP
- script from Adrian Mariano.
- .SH OPTIONS
- \fIxgoban\fP accepts all of the standard toolkit command line options as
- well as the following :
- .TP 8
- .B \-size \fIsize\fP
- This option specifies the size of the goban : \fIsize\fP must range between
- 2 and 19. It can be used in Play or Edit mode. The default size is 19.
- .TP 8
- .B \-handicap \fIhandicap\fP
- In Play mode, this option specifies the number of handicap stones that
- are to be put on the goban before the game starts.
- Legal values for \fIhandicap\fP depend on the size of the board and on
- the playing program.
- Whitin Edit mode, a first node is created and handicap stones are put
- under the AddBlack property.
- .TP 8
- .B \-black \fIblackplayer\fP
- This options indicates the name of the black player. \fIxgoban\fP
- is started within Play mode and \fIblackplayer\fP is added on the root
- node under the PlayerBlack property.
- \fIxgoban\fP recognize 2 program names : gnugo and wally.
- When \fIblackplayer\fP is one of them, an attempt is made to run the
- corresponding program (which must be found using the current environment variable
- PATH).
- .TP 8
- .B \-white \fIwhiteplayer\fP
- This option is the same as -black, but for the white player.
- .TP 8
- .B \-path \fIpath\fP
- This option specifies the path where files are searched before loading them.
- A \fIpath\fp is a comma separated list of directories.
- .TP 8
- .B \-pointSize \fIsize\fP
- This option specifies the size in pixels for a small square of the board.
- .TP 8
- .B \-nonumber
- This option turns off the automatic numbering facility.
- .TP 8
- .B \-silent
- .br
- This option turns off the bell.
- .B \-beep \fIvolume\fP
- .br
- This option specifies the volume of the bell when it is not turned off.
- Legal values range between -100 and 100.
- I am not sure it will work on all keyboards ...
- Default value is 0.
- .TP 8
- .B \-versatile
- This option turns off strong verification of the tree : see below.
- This also turns off the automatic numbering facility.
- .TP 8
- .B \-help
- .br
- Displays a list of allowed options.
- \fIxgoban\fP is not started.
- .TP 8
- .B [ \-mail | \-m ] \fImailfile\fP
- Start \fIxgoban\fP in Mail mode. A file should be specified with
- \fIfilename\fP argument. This file is read, and \fIxgoban\fP automatically
- moves to the end of the main variation.
- When you quit \fIxgoban\fP, the game tree will be saved to
- \fImailfile\fP. The exit value will be 0 if a move has been made
- and 1 otherwise. This option has been designed to work with the
- \fImailgo\fP script from Adrian Mariano (adrian@u.washington.edu).
- \-m option is for compatibility with \fImgt\fP.
- .TP 8
- .B [ \-short | \-s ]
- This option forces \fIxgoban\fP to save files in short mode : only
- uppercase letters of keywords are printed, and there is no carriage
- return. \-s option is for compatibility with \fImgt\fP.
- .TP 8
- .B -stipple<x>
- These options set the backgroundPixmap ressource of the Goban widget
- to predefined gray pixmaps (<x> must be one of 1, 2 or 3).
- You may like it if you use a black and white
- display. This is an idea of Stephen Coffin.
- .LP
- One of \-white, \-black option starts \fIxgoban\fP in Play mode.
- Default is Edit mode.
- .SH OPERATIONS
- .B
- When used in Edit mode, \fIxgoban\fP allows the user to edit go files.
- Commands are entered form the keyboard or from the mouse.
- Most of the window that are poped down contain a Confirm (or Yes) an a
- Cancel (or No) button.
- Escape key is associated with the Cancel button, while Return
- Key is associated with the Confirm button.
- .LP
- When an action is not allowed (because the mode your are in)
- you will hear a beep. Of course you hear nothing if you turned
- the bell off.
- .LP
- First are commands that can be used to only view a file :
- .LP
- .TP 8
- >
- Moves to next node along the tree and displays its properties.
- .LP
- .TP 8
- <
- Hides properties of current node and moves to previous node
- along the tree.
- .LP
- .TP 8
- }
- Goes down along the tree until a commented node or a variation node
- is seen.
- .LP
- .TP 8
- {
- Goes up along the tree until a commented node or the top of the tree
- is seen.
- .LP
- .TP 8
- ]
- Goes down along the tree until a variation node or the bottom of the
- tree is seen.
- .LP
- .TP 8
- [
- Goes up along the tree until a variation node or the top of the tree
- is seen.
- .LP
- .TP 8
- ?
- Pops down a short help window.
- .LP
- .TP 8
- q
- Exits from the program.
- .LP
- .TP 8
- l
- Loads a file.
- .LP
- .TP 8
- s
- Saves the current tree to a file.
- .LP
- .TP 8
- i
- Pops down a window that contains some properties of the current event
- (GameName, PlayerWhite, WhiteRank, WhiteSpecies ... and GameComment)
- You can change these properties or just view them.
- .LP
- .TP 8
- A-Z
- When there are some variations, an uppercase letter is displayed on each
- point corresponding to each possible move.
- The A-Z keys can be used to select the corresponding node.
- See also Btn2 action
- .LP
- .TP 8
- Btn1
- When there are variations and the mouse points at a marked point (with
- uppercase letter), selects the corresponding node.
- Otherwise it is the same as key `>'.
- .LP
- .TP 8
- Btn2
- It can arise that not all variations can be marked with an uppercase
- letter : if a variation is a diagram (having AddBlack, AddWhite or AddEmpty
- property), if there is variations on the same level
- with differently colored move (Black and White), or if there is a pass move.
- In this case, the cursor will be gray.
- Pressing the middle button pops up a menu where all variations are listed.
- You can choose the one you want to display
- .LP
- .TP 8
- Btn3
- Same as key `<'.
- .LP
- Following commands can be used to change a tree :
- .LP
- .TP 8
- v
- Enters the View sub-mode and allows the user to select a partial view of the
- board. A VieW property is then attached to the node.
- .LP
- .TP 8
- z
- Enters the Size sub-mode and allows the user to set the size of the board.
- SiZe property can only be change at Event node (see below) and the board
- is cleared.
- .LP
- .TP 8
- w
- Set the PLayer property to white for the current node.
- The next move will be a white stone.
- .LP
- .TP 8
- b
- Set the PLayer property to black for the current node.
- The next move will a black stone.
- .LP
- .TP 8
- n
- Prompt a dialog to edit the name of current node.
- .LP
- .TP 8
- a
- If the current node is a diagram,
- Enters the Diagram sub-mode and allows the user to edit the diagram.
- .LP
- .TP 8
- Shift Btn1
- Adds a move after the current node.
- The new node is created with property
- White or Black according to the color of the last move.
- The mouse must point on the intersection where you want to put the stone.
- .LP
- .TP 8
- Shift Btn3
- Deletes the current node and all its sub-nodes.
- .LP
- .TP 8
- Ctrl Shift Btn1
- Makes a variation move.
- The color is the same as the PLayer property of previous node.
- The mouse must point on the intersection where you want to put a the stone.
- .LP
- .TP 8
- Ctrl Shift P
- Makes a variation move which is a pass move.
- The color is the same as the PLayer property of previous node.
- .LP
- .TP 8
- Ctrl Shift Btn2
- Makes a variation diagram.
- It enters in the Diagram sub-mode (see below) to allow the user to put stones on
- the diagram.
- .LP
- .TP 8
- Ctrl Btn1
- Puts a letter (downcase) on the mouse pointed intersection.
- .LP
- .TP 8
- Ctrl Btn2
- Puts a triangle mark on the mouse pointed intersection.
- .LP
- .TP 8
- Ctrl Btn3
- Remove any letter or mark from the mouse pointed intersection.
- .LP
- There are sub-modes of Edit mode that can be Diagram, View or Size.
- Whitin these sub-modes, actions are changed.
- The Diagram sub-mode is signaled by a `point' cursor, while the View and
- Size sub-modes are signalled by the `upper-left-corner' cursor.
- .LP
- .TP 8
- Escape
- .br
- Quit the Diagram, Size or View sub-mode.
- .LP
- .TP 8
- Btn1
- Within Diagram sub-mode : puts a black stone on the mouse pointed intersection.
- .LP
- .TP 8
- Btn2
- Within Diagram sub-mode : puts a white stone on the mouse pointed intersection.
- .LP
- .TP 8
- Btn3
- Within Diagram sub-mode : removes any stone from the mouse pointed intersection.
- .LP
- .TP 8
- Btn1 Press
- Within View or Size sub-mode : start draging a rectangle to select the view
- or the size.
- .LP
- .TP 8
- Btn1 Motion
- Within View or Size sub-mode : drags the rectangle.
- .LP
- .TP 8
- Btn1 Release
- Within View or Size sub-mode : stop draging the rectangle and add a VieW or SiZe
- property to the current node.
- .SH GAME TREE
- Game trees that can be made are slightly different from Smart-Go format.
- I wanted them to be closer to a `real' game.
- .LP
- Node are either of type Diagram (they have AddBlack, AddWhite or AddEmpty property)
- or of type Move (they have Black or White property).
- Only a Diagram can have the PLayer property (default is PLayer[B]), which
- can be set only if the diagram does not have a successor.
- A file is a collection of Event nodes, which are of type Diagram.
- A node can have one or more successors (in which case, successors are variations).
- If a node has only one successor, that successor can only be of type Move.
- If a node is of type Move, the color of any successor can only be the opposite
- of its color.
- If a node is of type Diagram, the color of any successor is the same as the PLayer
- property of the diagram.
- .LP
- However, I noticed that most of the avaible game record doesn't match these restrictions.
- \fIxgoban\fP can read such unrestricted files but not edit them and create new
- unrestricted nodes.
- Thus I added a \-versatile option that turns off strong verification for accepted colors
- of nodes.
- When you specify \-versatile option, you can change the PLayer property even at Move nodes
- or at any node that already have a successor.
- .SH RESOURCES
- Resources can be set via xrdb or in the .Xdefault file.
- Default resources are as follow :
- .sp
- .nf
- .ta .5i
- XGoban*size : 19
- XGoban*handicap : 0
- XGoban*path : "."
- XGoban*pointSize : 26
- XGoban*autonum : True
- XGoban*beep : True
- XGoban*versatile : False
- .fi
- .LP
- You can change the board color if you want. Remember that the board background
- shouldn't be black : thus, on a black and white display the only valid background
- is white.
- .sp
- .nf
- .ta .5i
- XGoban*goban.background : tan1
- XGoban*goban.foreground : black
- .fi
- .LP
- But everything else can be black on a white background if you like it :
- .sp
- .nf
- .ta .5i
- XGoban*background : black
- XGoban*foreground : white
- XGoban*borderColor : white
- .fi
- .LP
- You can also control the geometry of windows :
- .sp
- .nf
- .ta .5i
- XGoban.geometry : 500x500+30+30
- XGoban.comment.geometry : 500x200+30+580
- .fi
- .LP
- You can change the translation table for the goban Widget (see xgoban.c for the
- default translation table). You must be carefull by doing this because of multiple
- modes. Some action work only in a specified mode, and you can bind them to the same
- event if they don't work in the same mode. But don't bind two actions working in the
- same mode with the same event ... you may have trouble.
- A good way to change the translation table is just to change the left part (name of
- events) and to leave the right part (action) as it is.
- To change the translation table see a doc on X Toolkit and modify your .Xdefaults
- accordly.
- .SH EXAMPLES
- .PD 0
- .TP 5
- To read and edit the file 001_001.s :
- .B xgoban 001_001.s
- .TP 5
- To play black against gnugo with 5 handicap stones :
- .B xgoban -handicap 5 -white gnugo
- .TP 5
- To play white against wally :
- .B xgoban -black wally
- .TP 5
- To make wally play against gnugo :
- .B xgoban -black wally -white gnugo
- .PD
- .SH BUGS
- .LP
- When read, a file is supposed to be syntacticaly correct.
- This is normally the case, when you didn't create this file by hand ...
- .LP
- File names are limited to 512 bytes.
- .LP
- \-pointSize option doesn't work with smaller size than 19x19.
- The board size is calculated as if it were a 19x19 board, and
- then the board size is changed whitin the same square.
- .LP
- Resign is not supported in Play mode, and you can't use the counting
- features of gnugo or wally.
- .LP
- Once you edit a file, you can't start editing another one without quiting
- \fIxgoban\fP. You can also delete all top nodes but beware from erasing you
- previous file with the save command.
- .SH SEE ALSO
- \fImgt\fP from Greg Hale.
- .br
- \fImailgo\fP from Adrian Mariano.
- .LP
- \fImgt\fP, \fImailgo\fP and game records
- are available at milton.u.washington.edu.
- .SH AUTHORS
- Antoine Dumesnil de Maricourt (dumesnil@etca.fr)
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'xgoban.ad'
- then
- echo shar: will not over-write existing file "'xgoban.ad'"
- else
- cat << \SHAR_EOF > 'xgoban.ad'
- ! On a black and white terminal, goban.background must be white and
- ! goban.foreground must be black ...
-
- XGoban*goban.background : tan1
- XGoban*goban.foreground : black
-
- ! Everything else can be white on a black foreground
-
- XGoban*background : black
- XGoban*foreground : white
- XGoban*borderColor : white
-
- ! Position of the windows ...
-
- XGoban.geometry : 500x500+30+30
- XGoban.comment.geometry : 500x200+30+580
-
- ! Default path and other options
- ! These options are overwriten by command line options
-
- XGoban.path : /users1/dumesnil/Go/games/mgt:/usr/local/games/go/files/mgt:.
-
- XGoban.autonum : True
- XGoban.beep : True
- XGoban.versatile : False
-
-
-
-
-
-
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'README'
- then
- echo shar: will not over-write existing file "'README'"
- else
- cat << \SHAR_EOF > 'README'
- Here are source files for a X11 go files editor
-
- The program has been tested under X11R5 on a sun4 (sparc) and under X11R4
- on a sun3 (68020)
-
- DISTRIBUTION :
- --------------
-
- You should find the following files :
-
- + CHANGE.Goban
- + Goban.c
- + Goban.doc
- + Goban.h
- + GobanP.h
- + Imakefile
- + README
- + action.c
- + blackstone.bm
- + dialog.c
- + display.c
- + event.c
- + game.c
- + go.c
- + go.h
- + graystone.bm
- + icon.bm
- + mailgo.6
- + misc.c
- + play.c
- + sg.c
- + stonemask.bm
- + whitestone.bm
- + xgoban.6
- + xgoban.ad
- + xgoban.c
- + xgoban.doc
- + xgoban.h
- + xgoban.man
- + xmailgo*
-
- BUILDING XGOBAN :
- -----------------
-
- Just type :
-
- > xmkmf
- > make depend
- > make
-
- If you want to install it with other X11 binary files, just do :
-
- > make install
- > make install.man
-
- To run it :
-
- > xgoban
-
- xgoban.ad is an example of configuration file. You can change it and add
- it into your .Xdefaults file.
-
- GOBAN WIDGET :
- --------------
-
- You can use the Goban widget for itself. Files related to it are :
-
- + Goban.c
- + Goban.doc
- + Goban.h
- + GobanP.h
- + blackstone.bm
- + graystone.bm
- + stonemask.bm
- + whitestone.bm
-
- For more description of the Goban widget see Goban.doc, and for xgoban
- see the manual pages (or xgoban.doc).
-
- WARNING :
- ---------
- If you get warning at compile time about types that don't match prototype
- description, you should ignore them. The program will (probably) work ...
- (this can appear mainly with XtAppAddInput; see below)
-
- You may have trouble to use wally or gnugo with xgoban. You need to add
- `fflush (stdout);' after the printf statements in gnugo and wally source
- files (line 144 in genmove.c for gnugo and line 1683 in wally.c for wally).
- You also can get an updated version (with fflush statement inside) for wally
- on anonymous ftp from milton.u.washington.edu (128.95.136.1).
-
- If it still doesn't work, maybe your OS doesn't support XtAppAddInput
- with pipe, or has trouble with streams : I can't do anything for
- you, but if you have a solution I will patch xgoban to use it.
-
- MAILGO :
- --------
-
- I included the mailgo script from Adrian Mariano in the distribution.
- It is renamed into xmailgo and the only difference is the default program that
- xmailgo try to run : xgoban of course. (you can use mailgo and set your
- environment variable MAILGO to xgoban to do the same job).
- It is a suggestion of Adrian Mariano.
-
- THANKS :
- --------
-
- I thank Adrian Mariano for the usefull remarks he made.
-
- BUGS :
- ------
-
- Bug descriptions, use reports, comments or suggestions are welcome.
- Send them to :
- dumesnil@etca.fr
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'CHANGE.Goban'
- then
- echo shar: will not over-write existing file "'CHANGE.Goban'"
- else
- cat << \SHAR_EOF > 'CHANGE.Goban'
- Changes to Goban Widget
-
- April 1 1992 :
- --------------
- + first version
-
- June 5 1992 :
- --------------
- + bugs corrected
- + backgroundPixmap resource added
-
- July 6 1992 :
- --------------
-
- + whiteStoneBackground, whiteStoneForground, whiteStoneBorder,
- blackStoneBackground, blackStoneForground, blackStoneBorder resources added
-
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'Imakefile'
- then
- echo shar: will not over-write existing file "'Imakefile'"
- else
- cat << \SHAR_EOF > 'Imakefile'
- MANSUFFIX = 6
- LOCAL_LIBRARIES = XawClientLibs
-
- SRCS = Goban.c read.c sg.c play.c dialog.c xgoban.c action.c \
- misc.c display.c game.c event.c write.c node.c
- OBJS = Goban.o read.o sg.o play.o dialog.o xgoban.o action.o \
- misc.o display.o game.o event.o write.o node.o
-
- ComplexProgramTarget (xgoban)
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'xmailgo'
- then
- echo shar: will not over-write existing file "'xmailgo'"
- else
- cat << \SHAR_EOF > 'xmailgo'
-
- #!/bin/sh
- #
- # mailgo 1.57 E-mail go game management program by Adrian Mariano
- # 6/5/92 I place it on the public domain. Please send improvements
- # to me at adrian@u.washington.edu.
- #
- # Syntax: mailgo [-r] filename
- # mailgo -n [filename]
- # mailgo -c
- #
- # Filename should contain a mailgo go game
- #
- # -r resends the file to the opponent
- # -n start a new game, using data in filename to get address
- # -c removes temporary files left when abnormally terminated
- #
- # Invokes the game processor in the environment variable MAILGO, or attempts
- # to run xgoban from the inherited path if MAILGO is not set.
- #
- # System V Unix users should change the assignment to the MAILER variable
- # from 'mail' to 'mailx' or 'elm' or some other compatible mailer.
- #
-
- MAILER=mail
-
-
- if [ $# -eq 0 ]
- then
- echo ' '
- echo 'Syntax: mailgo [-r] filename'
- echo ' mailgo -n [filename]'
- echo ' mailgo -c '
- echo ' '
- echo 'Mailgo is a program to manage email go games.'
- echo 'Filename should contain a mailgo go game'
- echo ' '
- echo ' -r resends the file to the opponent'
- echo ' -n start a new game, using data in filename to get address'
- echo ' -c removes temporary files left when abnormally terminated'
- echo ' '
- exit
- fi
- case $1 in
- -c) if [ $# -ne 1 ]
- then
- echo Wrong number of parameters
- exit
- else
- rm -f MailGo* MailFile* MailOut*
- exit
- fi;;
- -r) if [ $# != 2 ]
- then
- echo Wrong number of parameters
- exit
- fi
- if grep "\---GoGaMeEnD---" $2 >/dev/null 2>&1
- then
- name=`sed -n '2,5s/TO: //p' $2`
- hisfile=`sed -n '2,5s/TOFILE: //p' $2`
- echo Remailing response to $name, $hisfile
- $MAILER -s "Remailed Go Game: $hisfile" $name < $2
- exit
- else
- echo Invalid input file $2
- exit
- fi;;
- -n) if [ $# -gt 2 ]
- then
- echo Wrong number of parameters
- exit
- fi
- if [ $# -eq 2 ]
- then
- if [ ! -s $2 ]
- then
- echo File $2 not found.
- exit
- fi
- opponent=`sed -n '2,5s/TO: //p' $2`
- echo Opponent address: $opponent
- hisfile=`sed -n '2,5s/TOFILE: //p' $2`
- echo His game file: $hisfile
- me=`sed -n '2,5s/FROM: //p' $2`
- echo Your address: $me
- myfile=`sed -n '2,5s/FROMFILE: //p' $2`
- echo Your game file: $myfile
- else
- echo -n "Opponent address: "
- read opponent
- echo -n "Opponent game filename: "
- read hisfile
- echo -n "Your address: "
- read me
- echo -n "Your game filename: "
- read myfile
- fi
- echo -n "Black player name: "
- read bpname
- echo -n " rank: "
- read bprank
- echo -n "White player name: "
- read wpname
- echo -n " rank: "
- read wprank
- echo -n "Handicap: "
- read handicap
- echo -n "Komi: "
- read komi
- echo -n "Game record format (Long/Short/Extrashort): "
- read format
- case $format in
- L | l) format='L' ;;
- E | e) format='E' ;;
- *) format='S' ;;
- esac
- started=`date|awk '{print $3, $2, $6}'`
- if grep "W\[\]" $myfile >/dev/null 2>&1
- then
- echo -n "File $myfile contains game possibly in progress. Clobber (y/N)? "
- read res
- case $res in
- Y | y) ;;
- *) echo -n "Your game filename: "
- read myfile;;
- esac
- fi
- cat <<END_END >$myfile
- ---GoGaMeStArT---
- FROM: $me
- FROMFILE: $myfile
- TO: $opponent
- TOFILE: $hisfile
- NEWGAME
- FORMAT: $format
- END_END
- cat <<END_END > MailGo$$
- (
- ;
- GaMe[1]
- VieW[]
- SiZe[19]
- Comment[ Black: $bpname, $bprank
- White: $wpname, $wprank
- Handicap: $handicap
- Komi: $komi
- Started: $started
- ]
- PlayerBlack[$bpname]
- BlackRanking[$bprank]
- PlayerWhite[$wpname]
- WhiteRanking[$wprank]
- KoMi[$komi]
- DaTe[$started]
- END_END
- case $handicap in
- 2) echo "AB[dp][pd]" >> MailGo$$ ;;
- 3) echo "AB[dp][pd][pp]" >> MailGo$$ ;;
- 4) echo "AB[dd][dp][pd][pp]" >> MailGo$$ ;;
- 5) echo "AB[dd][dp][jj][pd][pp]" >> MailGo$$ ;;
- 6) echo "AB[dd][dj][dp][pd][pj][pp]" >> MailGo$$ ;;
- 7) echo "AB[dd][dj][dp][jj][pd][pj][pp]" >> MailGo$$ ;;
- 8) echo "AB[dd][dj][dp][jd][jp][pd][pj][pp]" >> MailGo$$ ;;
- 9) echo "AB[dd][dj][dp][jd][jj][jp][pd][pj][pp]" >> MailGo$$ ;;
- esac
- if [ 0$handicap -ge 2 -a $handicap -le 9 ]
- then
- echo "PL[W]HA[$handicap]" >> MailGo$$ ;
- fi
- echo ")" >> MailGo$$
-
- case $format in
- L) sflag='';;
- *) sflag=-s;;
- esac
- if ${MAILGO-xgoban} $sflag -m MailOut$$ MailGo$$
- then
- if [ -s MailOut$$ ]
- then
- cat MailOut$$ >>$myfile
- else
- cat MailGo$$ >>$myfile
- fi
- else
- echo -n "No move made, or xgoban error. Send anyway (y/N)? "
- read res
- case $res in
- Y | y) cat MailGo$$ >>$myfile;;
- *) echo NOT mailing new game.
- rm -f MailGo$$ MailOut$$
- exit;;
- esac
- fi
- rm -f MailOut$$ MailGo$$
- echo Mailing new game to $opponent, $hisfile
- echo >> $myfile
- echo "---GoGaMeEnD---" >> $myfile
- $MAILER -s "New Go Game: $hisfile" $opponent <$myfile
- exit
- ;;
- esac
- if [ $# -ne 1 ]
- then
- echo Wrong number of parameters
- exit
- fi
- if [ ! -s $1 ]
- then
- echo File $1 not found
- exit
- fi
- sed -n '/---GoGaMeStArT---/,/---GoGaMeEnD---/{s/---GoGaMe.*---//
- p
- }' $1 > MailGo$$
- if [ ! -s MailGo$$ ]
- then
- echo Invalid input file $1
- exit
- fi
- if sed -n 6,7p MailGo$$ | grep FORMAT > /dev/null 2>&1
- then
- format=`sed -n '6,7s/FORMAT: //p' MailGo$$`
- if [ ! \( $format = 'L' -o $format = 'E' \) ]
- then
- format='S'
- fi
- else
- format='L'
- fi
- case $format in
- L) sflag='';;
- *) sflag='-s';;
-
- # E) sflag='-s';;
- # S) sflag='-s'
- # sed -n -e 'H' -e '$g' -e '$s/\n;/;/g' -e '$s/^\n//' -e '$p' <MailGo$$ >MailGoX$$
- # mv -f MailGoX$$ MailGo$$ ;;
-
- esac
- if ${MAILGO-xgoban} $sflag -m MailOut$$ MailGo$$
- then
- echo >> MailOut$$
- echo ---GoGaMeStArT--- > MailFile$$
- sed -n '1,/(/s/FROM/TO/p' MailGo$$ >> MailFile$$
- sed -n '1,/(/s/TO/FROM/p' MailGo$$ >> MailFile$$
- echo FORMAT: $format >> MailFile$$
- if [ $format = 'S' ]
- then
- sed 's/\(;[BC]\[\)/\
- \1/g' MailOut$$ >>MailFile$$
- else
- cat MailOut$$ >> MailFile$$
- fi
- echo "---GoGaMeEnD---" >> MailFile$$
- name=`sed -n '2,5s/FROM: //p' MailGo$$`
- fileout=`sed -n '2,5s/TOFILE: //p' MailGo$$`
- tofile=`sed -n '2,5s/FROMFILE: //p' MailGo$$`
- if sed -n 6p MailGo$$ | grep NEW > /dev/null 2>&1 && [ -s $fileout ]
- then
- echo -n "File $fileout exists. Clobber (y/N)? "
- read res
- case $res in
- Y | y) rm -f $fileout ;;
- *) echo -n "Output filename: "
- read newfileout
- sed "2,5s/FROMFILE: $fileout/FROMFILE: $newfileout/" MailFile$$>Mfil$$
- mv Mfil$$ MailFile$$
- fileout=$newfileout ;;
- esac
- fi
- echo Mailing response to $name, $tofile
- $MAILER -s "Go Game: $tofile" $name < MailFile$$
- rm -f MailGo$$ MailOut$$ $1
- if grep "\---GoGaMeEnD---" $fileout > /dev/null 2>&1 || [ ! -s $fileout ]
- then
- mv MailFile$$ $fileout
- else
- echo Save file $fileout doesn\'t look like a mailgo file.
- echo "Overwrite it anyway (y/N)?"
- read res
- case $res in
- y | Y) mv -f MailFile$$ $fileout;;
- *) echo Game record left in MailFile$$;;
- esac
- fi
- else
- echo No move made, or xgoban error. NOT mailing response.
- rm -f MailGo$$ MailOut$$
- fi
- SHAR_EOF
- chmod +x 'xmailgo'
- fi # end of overwriting check
- if test -f 'mailgo.6'
- then
- echo shar: will not over-write existing file "'mailgo.6'"
- else
- cat << \SHAR_EOF > 'mailgo.6'
- .TH MAILGO 6 "5 April 1991"
- .SH NAME
- mailgo - shell script for using mgt to automate email go games
- .SH SYNOPSIS
- .B mailgo [\-r] [\-n] [\-c] [filename]
- .SH DESCRIPTION
- .B mailgo
- helps manage email games by processing Smart-Go game records received by
- mail, invoking mgt, and automatically sending your next move back.
- .LP
- Invoking
- .B mailgo
- with no flags instructs the program to search the specified file for a
- go game, ignoring mail headers or other such garbage.
- .B mailgo
- will invoke the game processor specified in the environment variable
- MAILGO or of this variable is undefined, will attempt to run
- .B mgt
- from the inherited path.
- .LP
- If your opponent loses your move, you can resend the game with the \-r
- switch.
- .LP
- To start a new game, use the \-n switch. Without a file, you will be
- prompted for your address, your opponent's address, and the filename for
- both your and your opponent's local game record. The game processor will
- then be invoked for you to make the first move. If a filename is specified,
- the address and filename data is taken from that file.
- .LP
- The \-c flag causes the program to delete any extraneous files it might have
- created during a previous run which was abnormally terminated.
- .SH FILE FORMAT
- .LP
- .sp
- .if
- Leading garbage ignored
-
- ---GoGaMeStArT---
- TO: opponent@hissite
- TOFILE: his_game_record
- FROM: me@mysite
- FROMFILE: my_game_record
- FORMAT: format_code
- (
- Smart\-Go game data
- )
- ---GoGaMeEnD---
-
- Trailing garbage ignored
- .fi
- .LP
- The game data file contains a leading tag to indicate the start of
- the data. It contains both addresses, as should be used to mail the
- game files, and it contains the files to store the games in. In the
- example above, you are playing opponent@hissite, and the game is being
- stored in my_game_record.
- .LP
- The file format used can be either long, short, or extrashort indicated by L,
- S, and E respectively. The long format uses the full size Smart-Go file
- saved with no options from mgt. The extrashort format uses mgt with the \-s
- option to save short format files. This format may cause problems for some
- mailers, however, because the lines will grow longer than 512 bytes.
- The short format is similar to the extrashort format but has extra newlines
- inserted. The short format is the default when selecting format from
- the prompt, but the long format is the default if a file contains no FORMAT
- line.
- When
- .B mailgo
- is used normally, the file specified on the command line is removed at
- successful completion, and the new game is saved to the file specified in
- the received game record. If the destination file does not look like
- a mailgo file,
- .B mailgo
- will query for confirmation.
- .SH FILES
- mgt
- .LP
- Smart-Go.def, the Smart\-Go format definition.
- .sp
- .SH BUGS
- .LP
- If you attempt to start a new game, but are not the first player to make a
- real move, then you will have to convince mgt that you have changed the game
- record. Do this by pressing z twice on a blank spot to set and remove a black
- stone.
- .fi
- .sp
- .SH AUTHOR
- Adrian Mariano (adrian@u.washington.edu)
- SHAR_EOF
- fi # end of overwriting check
- # End of shell archive
- exit 0
-